Rulvar API reference / @rulvar/openai / reconcileStatement
Function: reconcileStatement()
function reconcileStatement(
invoice,
statement,
options): StatementReconciliation;Defined in: packages/core/dist/index.d.ts
Reconciles the invoice against a normalized provider export. Pure and journal-free; see the module doc for the contract. Throws a typed ConfigError on inputs that cannot be evidence: an empty statement (a headline total with no rows), a request row without a response id, a duplicate response id on either side (an ambiguous join, statement rows and local invoice rows alike, RV1804), a request export whose rows carry neither dollars, components, nor usage, any non-finite or negative dollar amount, any non-integer or negative token count, a non-finite or negative tolerance (RV903: a statement that cannot be summed must refuse loudly, never verdict 'match' on NaN totals), or a row whose usd and componentsUsd contradict each other beyond totalToleranceUsd (RV1005: an internally contradictory export is not evidence either).
Parameters
| Parameter | Type | Description |
|---|---|---|
invoice | { orphanedReceipts?: { rows: readonly { responseId?: string; }[]; }; rows: readonly InvoiceRow[]; unsettled?: { rows: readonly { responseId?: string; }[]; }; } | - |
invoice.orphanedReceipts? | { rows: readonly { responseId?: string; }[]; } | - |
invoice.orphanedReceipts.rows | readonly { responseId?: string; }[] | - |
invoice.rows | readonly InvoiceRow[] | - |
invoice.unsettled? | { rows: readonly { responseId?: string; }[]; } | The invoice's receipt lanes (RV3405), passed straight off the InvoiceExport when the caller wants statement rows for crashed or terminal forgotten wires EXPLAINED instead of counted foreign. Requests mode only (the join is by response id), and strictly opt in: a bare { rows } invoice reads byte for byte as before. |
invoice.unsettled.rows | readonly { responseId?: string; }[] | - |
statement | ProviderStatement | - |
options | ReconcileStatementOptions | - |