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 /
toBeInvoicedon 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: falseon inspection queries). - Invoice approval on a contact profile (
invoiceApproved) can auto-settoBeInvoicedon 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(orinvoiceApproved). 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 includepaid,remainingBalance, etc., but nottoBeInvoiced. Add a boolean condition entry following the same pattern aspaid(e.g. display label such as “To be invoiced” / “Invoice terms”). - Action flow builder uses the shared
Conditionscomponent andinspectionConditionalKeysfromtemplatingData.ts; new key should appear wherever inspection-level conditions are offered for email/SMS actions. - Related product surfaces (context only):
toBeInvoicedis toggled inattik-frontend/src/app/tools/inspections/[id]/components/ServicesPayments.tsx; report/portal behavior uses it ingetReportLockMessage.ts,ReportList.tsx, andattik-frontend/src/app/client/job/[slug]/page.tsx(sectionStatus.paidis stillinspection.paid, independent oftoBeInvoiced). - Decision needed: Whether contact-level
invoiceApprovedshould also be a flow condition (per-contact “invoice approved” onContactForm.tsx), or job-leveltoBeInvoicedalone is sufficient for v1.
Backend
- Condition evaluation:
attik-backend/src/util/functions/actionFlows/attributePathResolver.ts— resolves inspection fields forevaluateConditionsinconditionsResolver.ts. Add resolver fortoBeInvoicedmirroringpaid(boolean on inspection). - Inspection model:
toBeInvoicedexists onattik-backend/src/models/inspectionSchema.tsand is set/updated viaattik-backend/src/routes/inspection.tsandcreateInspection.ts(from contactinvoiceApproved+ pay role at create). - Send paths (unchanged behavior unless conditions added): Action flow email/SMS still target recipients by role and
preferredContactMethodinemailBuilder/renderEmail.tsandactionFlows/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
toBeInvoicedwithout 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/smsStatussubscribe flags on Action flow sends (separate gap).
References
attik-frontend/src/components/conditions/templatingData.tsattik-backend/src/util/functions/actionFlows/attributePathResolver.tsattik-backend/src/util/functions/actionFlows/conditionsResolver.tsattik-backend/src/models/inspectionSchema.ts(toBeInvoiced)attik-frontend/src/app/tools/inspections/[id]/components/ServicesPayments.tsxattik-backend/src/util/functions/inspection/checkReportAccess.tsattik-backend/src/util/functions/inspection/createInspection.ts(invoiceApproved→toBeInvoicedat job create)