Objective
- Resolve confusion—and possible incorrect client-facing invoices—when a work order shows Paid / $0 service balance but the invoice PDF still shows balance due for an uncollected technology fee.
- Give staff and clients a consistent, trustworthy payment story on jobs where pass-through card fees are enabled (
feeDisabledfalse) but the technology fee was not collected with the service payment. - Reduce support escalations like RIA2159, where a buyer’s agent received an invoice for $17.95 owed (technology fee amount) while the order appeared paid and the agreement was signed.
Background
- Support report (Amber / BA): On job RIA2159, the buyer’s agent got an invoice showing $17.95 balance due—the technology fee amount. Internal staff see $0 balance on the work order, job Paid, agreement signed, technology fee not disabled, but the technology fee not paid.
- Triage finding — two different totals today:
- Work order (Services & Payments): Total, Payments, and Balance use service charges only. When
remainingBalanceis $0, the green PAID chip appears—even if a technology fee is still outstanding. - Invoice PDF (email attachment / client-facing): Total amount due uses
totalWithFees(services + technology fees). Balance due = that figure minus service payments + fees actually collected on completed payments. - A job can therefore show Paid internally while an invoice correctly (per current code) shows fee still owed—or, in some data cases, show a fee balance when staff believe no fee should apply.
- Invoice generation does not currently consider
feeDisabledwhen computing balance; Disable CC Fees on the work order affects future card payments, not how existing invoice PDFs interpret stored fee rollups. - Example repro pattern: pass-through fees enabled, service payment completed without the technology fee collected → work order $0 balance / PAID, invoice Balance due: $17.95.
Triage verdict (starting point)
- Primary: Edge case / training gap — work order “paid” and invoice “balance due” can both be technically correct under current rules when the technology fee is still owed.
- Investigate on RIA2159: Confirm payment type and whether a Technology Fee row exists under the payment. If no fee row but invoice still shows $17.95, treat as possible stale or incorrect
totalWithFeesrollup (bug). - Product decision needed: Should client-facing invoice balance match work order paid status when only an uncollected technology fee remains, or should invoice continue to show fee owed with clearer staff/client messaging?
Scope
Backend (attik-backend)
src/util/functions/forecast/syncTotalsOnInspections.ts—remainingBalance,paid,totalFees, andtotalWithFeesrollups; paid is based on service total vstotalPaid, not full fee-inclusive total.src/util/functions/payments/invoicePdfPaymentHelpers.ts—invoicePdfHeadlineAmountDue,calculateTotalAmountPaid,totalFeesPaid(invoice-side fee math).src/util/functions/pdf/templates/InvoiceAttachmentPDF.tsx— backend invoice PDF attachment (parity with frontend invoice logic).src/models/inspectionSchema.ts—feeDisabled,totalWithFees,totalFees,remainingBalance.src/routes/guardianPayments.ts— pass-through fee recording on card payments whenfeeDisabledis false.
Frontend (attik-frontend)
src/app/tools/inspections/[id]/components/ServicesPayments.tsx— work order Total / Payments / Balance and PAID chip; Disable CC Fees / Enable CC Fees actions.src/components/invoice/InvoicePDF.tsx— client invoice PDF:invoicePdfHeadlineAmountDue, balance due vs PAID status on PDF.src/util/functions/payments/calculateTotalAmountPaid.ts— shared invoice payment/fee totals (mirrors backend helpers).tests/unit/invoicePdfTotals.test.ts— documents intentional behavior: invoice headline includes technology fee (ATT-1398 pattern).
Out of scope (unless investigation expands)
- QuickBooks sync totals (separate comparison path on Integrations tab).
- Changing pass-through fee percentage or payment processor behavior without a product decision.
Done when
- [ ] RIA2159 (or equivalent repro job) reviewed: payment type, fee row presence, and whether $17.95 balance is correctly owed vs data error.
- [ ] Product decision documented: expected client/staff experience when services paid but technology fee uncollected with fees not disabled.
- [ ] If change is warranted: work order, invoice PDF, and/or action-flow invoice sends present a consistent story (implementation approach left to dev).
- [ ] If no code change: support guidance added (internal) explaining service balance vs invoice balance including technology fee.
References
- Triage source: support report RIA2159 (Amber / buyer’s agent invoice).
attik-backend/src/util/functions/forecast/syncTotalsOnInspections.tsattik-frontend/src/components/invoice/InvoicePDF.tsxattik-frontend/src/util/functions/payments/calculateTotalAmountPaid.tsattik-frontend/src/app/tools/inspections/[id]/components/ServicesPayments.tsx