Skip to main content

Function: assignmentEffectiveOn()

assignmentEffectiveOn(svc, companyId, contractorId, dateISO): Promise<EffectiveAssignment | null>

Defined in: src/server/services/assignments.ts:22

The contractor's assignment in effect on dateISOeffective_date <= date AND (end_date IS NULL OR end_date >= date), newest-effective first. Returns null when no assignment covers the date.

This is the canonical "is this contractor assigned on this day?" check (it mirrors the rule in performance.ts and the admin dashboard). Time entries MUST resolve their assignment this way — grabbing the latest active assignment regardless of date lets hours attach to an assignment that isn't effective for the entry's date, which then silently drops out of pay (no matching rate).

Parameters

svc

SupabaseClient

companyId

string

contractorId

string

dateISO

string

Returns

Promise<EffectiveAssignment | null>