Action flows: add condition for jobs marked to be invoiced

Objective

  • Let companies configure Action flows (payment reminders and other automated emails/texts) to skip or branch when a job is on invoice terms (toBeInvoiced), so clients marked to be invoiced are not nagged to pay online.
  • Align automated messaging with how invoice jobs already behave elsewhere in the product (reports unlock without payment; jobs can drop off “not paid” worklists).

Background

  • Jobs can be marked to be invoiced on the work order (Allow invoice terms / toBeInvoiced on the inspection). That flag means payment is not required to unlock reports when agreements are satisfied, and the job can be excluded from internal lists that filter out invoiced work (invoiced: false on inspection queries).
  • Invoice approval on a contact profile (invoiceApproved) can auto-set toBeInvoiced on new Attik jobs when the contact has a portal role with pay permission and invoice approval is enabled at scheduling time.
  • There is no Action flow condition today for toBeInvoiced (or invoiceApproved). Staff cannot build rules such as “do not send this payment reminder if the job is to be invoiced.”
  • Using Paid is false does not substitute: a job can be to be invoiced and still unpaid, so payment-reminder flows conditioned only on “not paid” continue to fire.
  • Contact-level Email subscribed / SMS subscribed and preferred contact method are separate levers; they are not tied to invoice terms and do not fully gate Action flow sends today.

Scope

Frontend

  • Condition picker (inspection / job flows): attik-frontend/src/components/conditions/templatingData.ts — inspection keys include paid, remainingBalance, etc., but not toBeInvoiced. Add a boolean condition entry following the same pattern as paid (e.g. display label such as “To be invoiced” / “Invoice terms”).
  • Action flow builder uses the shared Conditions component and inspectionConditionalKeys from templatingData.ts; new key should appear wherever inspection-level conditions are offered for email/SMS actions.
  • Related product surfaces (context only): toBeInvoiced is toggled in attik-frontend/src/app/tools/inspections/[id]/components/ServicesPayments.tsx; report/portal behavior uses it in getReportLockMessage.ts, ReportList.tsx, and attik-frontend/src/app/client/job/[slug]/page.tsx (sectionStatus.paid is still inspection.paid, independent of toBeInvoiced).
  • Decision needed: Whether contact-level invoiceApproved should also be a flow condition (per-contact “invoice approved” on ContactForm.tsx), or job-level toBeInvoiced alone is sufficient for v1.

Backend

  • Condition evaluation: attik-backend/src/util/functions/actionFlows/attributePathResolver.ts — resolves inspection fields for evaluateConditions in conditionsResolver.ts. Add resolver for toBeInvoiced mirroring paid (boolean on inspection).
  • Inspection model: toBeInvoiced exists on attik-backend/src/models/inspectionSchema.ts and is set/updated via attik-backend/src/routes/inspection.ts and createInspection.ts (from contact invoiceApproved + pay role at create).
  • Send paths (unchanged behavior unless conditions added): Action flow email/SMS still target recipients by role and preferredContactMethod in emailBuilder/renderEmail.ts and actionFlows/renderSms.ts; no invoice check today.
  • Decision needed: Whether default/example payment-reminder flows should be updated in seed/docs, or only expose the new condition for companies to configure.

Out of scope (unless product asks)

  • Automatically suppressing all payment-related sends when toBeInvoiced without company-configured flow conditions (this issue is about making the condition available, not changing every flow by default).
  • Changing report-lock or portal payment UI logic (already defined in checkReportAccess.ts).
  • Fully enforcing emailStatus / smsStatus subscribe flags on Action flow sends (separate gap).

References

  • attik-frontend/src/components/conditions/templatingData.ts
  • attik-backend/src/util/functions/actionFlows/attributePathResolver.ts
  • attik-backend/src/util/functions/actionFlows/conditionsResolver.ts
  • attik-backend/src/models/inspectionSchema.ts (toBeInvoiced)
  • attik-frontend/src/app/tools/inspections/[id]/components/ServicesPayments.tsx
  • attik-backend/src/util/functions/inspection/checkReportAccess.ts
  • attik-backend/src/util/functions/inspection/createInspection.ts (invoiceApprovedtoBeInvoiced at job create)

Please authenticate to join the conversation.

Upvoters
Status

Planned

Board
🏠

Main App

Date

12 days ago

Author

Linear

Subscribe to post

Get notified by email when there are changes.