Function: buildSupplementalPreview()
buildSupplementalPreview(
companyId,parentInvoiceId,opts?):Promise<SupplementalPreview| {error:string; }>
Defined in: src/server/services/invoice/supplemental.ts:68
Compute (without persisting) the supplemental for a parent invoice's week: the family's unbilled delta per parent-line assignment, priced at each parent line's frozen rate. Read-only.
Refusals: parent not found / void / deleted; a draft parent (recompute it in place instead); a backfilled parent (historical AR has no billing week to reconcile against); a supplemental parent (supplement the ORIGINAL invoice — families don't nest); an open supplemental draft already covering this parent (send or void it first — one open draft at a time, ADR-0055).
Parameters
companyId
string
Tenant scope.
parentInvoiceId
string
The drifted (or suspected-drifted) parent invoice.
opts?
forDraftId: recompute the delta AS IF that open supplemental draft didn't exist —
its own lines leave the billed tally and it doesn't trip the one-open-draft refusal. This is the
send-time staleness check for that draft (performSend): "would creating this supplemental now
still produce the stored total?" Creation previews omit it.
forDraftId?
string
Returns
Promise<SupplementalPreview | { error: string; }>
The preview (possibly with empty lines — the family is clear) or { error }.