Interface: FacilityRunRow
Defined in: src/lib/invoice/run.ts:33
One facility's row in a weekly billing run — a camelCase projection of a single
weekly_billing_run() SQL output row. Billing weeks are the unified Mon–Sun week — the same anchor
the pay engine uses (ADR-0044).
All monetary fields are integer cents (never floats/dollars). Hour fields are decimal hours.
billableAmountCents reflects the billing policy applied in SQL — bill the lesser of logged vs.
contracted unless an overage has been approved — so it may be less than loggedHours × rate.
Properties
activeAssignmentCount
activeAssignmentCount:
number
Defined in: src/lib/invoice/run.ts:58
Number of currently active assignments at this facility.
approvedHours
approvedHours:
number
Defined in: src/lib/invoice/run.ts:47
Logged hours that have been approved. Decimal hours.
billableAmountCents
billableAmountCents:
number
Defined in: src/lib/invoice/run.ts:51
Amount to bill this facility this week, in integer cents (post-policy; see interface doc).
contractedHours
contractedHours:
number
Defined in: src/lib/invoice/run.ts:43
Contracted hours for the week (the cap for non-overage billing). Decimal hours.
coverageGap
coverageGap:
boolean
Defined in: src/lib/invoice/run.ts:67
true when a coverage gap was detected (drives status === 'gap').
existingInvoiceDrifted
existingInvoiceDrifted:
boolean
Defined in: src/lib/invoice/run.ts:81
true when this row's existing invoice is issued (sent/partial/overdue) and its recorded hours
changed after it was sent — billable hours in its period+assignments were logged but never locked
to it (see the invoice_drift view). Drives the cockpit's "hours changed — review" nudge.
existingInvoiceId
existingInvoiceId:
string|null
Defined in: src/lib/invoice/run.ts:71
Id of an invoice already raised for this facility/week, or null if none exists yet.
existingInvoiceNumber
existingInvoiceNumber:
string|null
Defined in: src/lib/invoice/run.ts:73
Human-facing number of the existing invoice, or null.
existingInvoiceStatus
existingInvoiceStatus:
string|null
Defined in: src/lib/invoice/run.ts:75
Status of the existing invoice (e.g. draft/sent/paid), or null.
facilityCity
facilityCity:
string|null
Defined in: src/lib/invoice/run.ts:39
Facility city, or null if unknown.
facilityId
facilityId:
string
Defined in: src/lib/invoice/run.ts:35
Facility UUID.
facilityName
facilityName:
string
Defined in: src/lib/invoice/run.ts:37
Facility display name.
facilityState
facilityState:
string|null
Defined in: src/lib/invoice/run.ts:41
Facility state, or null if unknown.
hasBillingContact
hasBillingContact:
boolean
Defined in: src/lib/invoice/run.ts:65
true when the facility has a designated billing contact to send the invoice to (active contact
with an email and role billing/admin); when false, drives status === 'review'.
loggedHours
loggedHours:
number
Defined in: src/lib/invoice/run.ts:45
Total hours logged by assigned people this week. Decimal hours.
missingRate
missingRate:
boolean
Defined in: src/lib/invoice/run.ts:60
true when at least one assignment lacks a billing rate (blocks a clean invoice; drives status === 'review').
peopleCount
peopleCount:
number
Defined in: src/lib/invoice/run.ts:56
Number of distinct contractors assigned to this facility this week (deduped per contractor across assignments; includes those who logged zero hours).
status
status:
RunStatus
Defined in: src/lib/invoice/run.ts:83
Derived per-facility run status computed in SQL. See RunStatus.
unapprovedHours
unapprovedHours:
number
Defined in: src/lib/invoice/run.ts:49
Logged hours still awaiting approval. Decimal hours.
varianceFlagged
varianceFlagged:
boolean
Defined in: src/lib/invoice/run.ts:69
true when logged-vs-contracted variance exceeded the review threshold (informational only; does not affect status).