Invoice shows agent name instead of client name

Objective

  1. 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.
  2. 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

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 optional invoiceContactOverride, otherwise the first inspection.people row whose role name contains "buyer" or "client" (case-insensitive substring match).
  • attik-frontend/src/components/invoice/InvoiceDrawer.tsx — Drives preview/download, builds invoiceContactOverride from the user's selected contact, and persists _invoiceContactId on the inspection via PATCH inspection/:id when 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), and attik-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; resolves invoiceContactEffective from optional override, else resolveInvoiceContactFromInspection (walks people for _invoiceContactId), else the same substring "buyer" / "client" fallback as the frontend PDF.
  • attik-backend/src/util/functions/emailBuilder/buildTemplateEmailAttachments.ts — When attachInvoicePdf is enabled on an email template, builds the attachment with InvoiceAttachmentPDF (same resolution rules as above).

Data / product

  • Inspection _invoiceContactId is defined on the inspection type (attik-frontend/src/util/types/serverTypeCollection/inspection.ts) and patched in attik-backend/src/routes/inspection.ts when 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 _invoiceContactId vs 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

Please authenticate to join the conversation.

Upvoters
Status

Completed

Board
🏠

Main App

Date

24 days ago

Author

Linear

Subscribe to post

Get notified by email when there are changes.