Invoice shows agent name instead of client name
Objective
- Correct "Invoice to" identity so invoices consistently show the intended client name (and company line when applicable), not a client's agent or other role, across every surface customers and staff rely on.
- Align behavior wherever the invoice PDF is produced or previewed so the same rules apply after modify invoice / contact flows and for automated invoice attachments.
Background
- Symptom: On affected orders, the "Invoice to" line shows the client's agent (or another non-client party) as the default instead of the client's name—in invoice preview, modify flow, client portal PDF invoice view, and downloaded PDF.
- Examples (production links):
- AJF: https://www.attik.ai/inspections/1008589497
- RIA and CHI: https://www.attik.ai/inspections/1008589839
- Related RIA order (invoice was later modified to show the client's name): https://www.attik.ai/inspections/1008589291
- Screen recording (repro / context—same embed as on the issue today):
Screen Recording 2026-05-06 at 3.00.43 PM.mov
Scope
Frontend
attik-frontend/src/components/invoice/InvoicePDF.tsx— Renders the PDF used in previews and downloads; "Invoice to" comes from optionalinvoiceContactOverride, otherwise the firstinspection.peoplerow whose role name contains"buyer"or"client"(case-insensitive substring match).attik-frontend/src/components/invoice/InvoiceDrawer.tsx— Drives preview/download, buildsinvoiceContactOverridefrom the user's selected contact, and persists_invoiceContactIdon the inspection viaPATCH inspection/:idwhen staff save the invoice contact.- Entry points that mount the drawer include
attik-frontend/src/app/tools/inspections/[id]/components/ServicesPayments.tsx(tools work order),attik-frontend/src/app/client/job/[slug]/components/JobAccordion.tsx(client portal job accordion), andattik-frontend/src/app/client/job/[slug]/pay-beta/PaymentBetaClient.tsx(pay flow).
Backend
attik-backend/src/util/functions/pdf/templates/InvoiceAttachmentPDF.tsx— Server-side invoice PDF used for email attachments and other backend generation; resolvesinvoiceContactEffectivefrom optional override, elseresolveInvoiceContactFromInspection(walkspeoplefor_invoiceContactId), else the same substring"buyer"/"client"fallback as the frontend PDF.attik-backend/src/util/functions/emailBuilder/buildTemplateEmailAttachments.ts— WhenattachInvoicePdfis enabled on an email template, builds the attachment withInvoiceAttachmentPDF(same resolution rules as above).
Data / product
- Inspection
_invoiceContactIdis defined on the inspection type (attik-frontend/src/util/types/serverTypeCollection/inspection.ts) and patched inattik-backend/src/routes/inspection.tswhen body fields are applied to the inspection document.
Decision needed
- What the canonical "invoice to" identity should be when multiple people qualify (e.g. primary client only vs explicit
_invoiceContactIdvs role ordering)—not prescribed here; the dev should choose after reproducing on the linked inspections.
References
- Tools invoice drawer host:
attik-frontend/src/app/tools/inspections/[id]/components/ServicesPayments.tsx - Client portal invoice entry:
attik-frontend/src/app/client/job/[slug]/components/JobAccordion.tsx - Backend email attachment path:
attik-backend/src/util/functions/emailBuilder/buildTemplateEmailAttachments.ts
Status: Completed
Log in to comment and vote
No comments yet
Be the first to share your thoughts.