Skip to main content

Function: computeInvoiceLines()

computeInvoiceLines(inputs, thresholdPct, periodStart, periodEnd): InvoiceComputation

Defined in: src/lib/invoice/index.ts:228

Compute all invoice lines for a facility's billing period (one Sunday-anchored week per the billing calendar). For each input: bills the lesser of actual/contracted hours (or full actual when the overage is approved), prices it at the hourly rate, computes the variance, and flags the line for review when the gap exceeds thresholdPct and the overage was not approved. Pure — no I/O.

Parameters

inputs

readonly InvoiceLineInput[]

The per-contractor billing facts for the period.

thresholdPct

number

The facility's variance-flag threshold, as a percentage. A line is flagged only when its variance is STRICTLY greater than this value (and the overage isn't approved).

periodStart

CalendarDate

The billing-period start date (used in each line's description).

periodEnd

CalendarDate

The billing-period end date (used in each line's description).

Returns

InvoiceComputation

An InvoiceComputation: the computed lines, their summed totalCents (integer USD cents; header always equals Σ lines), and anyVarianceFlagged.