Skip to main content

Function: loadWeekBillingFacts()

loadWeekBillingFacts(svc, companyId, facilityId, weekStart, opts?): Promise<WeekBillingFact[]>

Defined in: src/server/services/invoice/weekFacts.ts:100

Load the per-contractor billing facts for one facility week.

  • Assignment window: effective_date ≤ weekEnd and (end_date null or ≥ weekStart); no active filter (an ended-but-in-window assignment still bills — see fetchInvoiceShelf's note).
  • requireRate: true (the generator) excludes null-rate assignments BEFORE the per-contractor pick — preserving the generator's existing behavior of billing an older rated assignment when the newest one has no rate. The shelf omits it so null-rate rows surface the "No rate" warning.
  • Overage approval matches by assignment id OR contractor id (same as the SQL surfaces).

Parameters​

svc​

SupabaseClient

companyId​

string

facilityId​

string

weekStart​

CalendarDate

opts?​

requireRate?​

boolean

Returns​

Promise<WeekBillingFact[]>

One fact per live contractor (empty when none in window). Throws on any failed read — see orThrow; a partially loaded week must never price.