Task 5 of the non-invoiceable-order-extras plan. buildQbInvoicePayload now keeps order_item_ids built from ALL rows (so n8n's 'Build PocketBase Invoice Update' node flips excluded rows to invoiced alongside their siblings — the order closes normally), and builds items from BILLABLE rows only (so QuickBooks never learns about the excluded lines). billableRows helper exported for sharing with the invoice UI (Task 6) and the delivery-note route (Task 7) — three callers, one definition of 'billable'. Added exclude_from_invoice to RawInvoicingRow AND the INVOICING_FIELDS projection. The projection is load-bearing: omit it and PB returns undefined, every extra silently bills the customer. Confirmed by inspection and by the failing 'mixed set' test if the projection drifts. 4 tests + 1 mutation-test prove the split: - mixed: excluded ids in order_item_ids, absent from items - all-billable: identical output to the no-flag case - all-excluded: empty items, full order_item_ids - billableRows helper unit tests - mutation (items built from input.rows): mixed and all-excluded tests fail Co-Authored-By: Claude <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| app | ||
| components | ||
| lib | ||
| styles | ||
| middleware.ts | ||
| test-setup.ts | ||