Function: payPeriodForDate()
payPeriodForDate(
d,contractorType,assignmentEndDate?):BiMonthlyPeriod
Defined in: src/lib/pay/settlement.ts:66
The bi-monthly period whose pay run actually PAYS a given entry date — which is not always the
calendar period containing it. Mirrors calculateContractorPay's dispatch exactly:
in_house_admin→ the calendar period (in-house pay is period-level).- outsourced with the assignment ending on or before the calendar period's end → the calendar
period (the terminating run day-prorates
[first settling Monday, end_date]— ADR-0057, so it also covers the prior period's tail days, which is why the weekly branch below is still correct for them: their week's Sunday lands in the terminating period). - outsourced otherwise → the period holding the date's ISO-week SUNDAY (weekly settling,
ADR-0044) — so a period's tail days past its last Sunday settle in the NEXT period's run.
Anything asking "which run pays / paid this date" (e.g. stranded-late-hours detection, ADR-0056)
must use this, never
periodForDatealone.