Skip to main content

Function: estimateContractorPay()

estimateContractorPay(companyId, contractorId, period): Promise<ContractorPayEstimate | null>

Defined in: src/server/services/payroll.ts:348

Estimate one contractor's pay for a period from the hours logged so far — the same engine and inputs as the period close, scoped to a single (own) contractor. Returns null when the contractor has no rate-bearing assignment overlapping the period. Read-only; safe to show the contractor.

Parameters​

companyId​

string

Tenant scope; every query is filtered to this company.

contractorId​

string

The contractor whose own estimate is requested (their dashboard view).

period​

BiMonthlyPeriod

The bi-monthly half to estimate.

Returns​

Promise<ContractorPayEstimate | null>

A ContractorPayEstimate aggregated across the contractor's assignments, or null if they have no rate-bearing assignment overlapping the period.

Remarks​

Shares computePayRun's loader/assembly (payInputs.ts), scoped to this one contractor — so the settling-week fetch window (ADR-0044), approved-overage seam, payable-status filter, and holiday routing are the same code, not a mirror. Per assignment, pay caps at the contracted rate unless that week's overage was approved. A contractor with no row defaults to 'outsourced'. Assignments whose pay-engine Result is an error are silently skipped (this is an estimate, not the authoritative close). The silent-skip tolerance covers only that Result error branch: a non-integer or unsafe bimonthly_rate_centavos still throws MoneyError via centavos() and aborts the estimate (unreachable in practice because the column is a bigint).