Function: applyManualPayoutDeductions()
applyManualPayoutDeductions<
L>(lines,manualPaidByContractor):object
Defined in: src/lib/payroll/index.ts:257
Deduct already-recorded manual (out-of-band) payouts from a run's per-assignment lines: each
contractor's deduction is subtracted greedily across their lines in order, lines reduced to zero
are dropped (same rule as a computed-zero line — no empty payslip), and a partially reduced
line's hoursWorked/contractedHours/ratio (when present) scale by the same fraction — the
surviving line pays for the remainder of the period, and the manual payout row carries the
covered share, so a period's hours are never claimed twice across the two payment rows.
Returns per contractor both the actually-deducted amount (so the preview can show WHY a figure shrank) and the UNAPPLIED remainder — a recorded payout exceeding the contractor's lines saturates (never goes negative — the run cannot claw money back), and the surplus is a possible over-payment the preview must surface rather than clamp silently. A payout for a contractor with no lines is wholly unapplied.
ponytail: multi-assignment hour split is inexact — the payout row's share is proportional to the contractor's TOTAL (recorded at entry time, before lines exist), while this deduction is greedy per line, so a multi-facility contractor's hours can sum under actual across the rows. Money is exact; single-assignment (the common case) is exact on hours too. Upgrade path if it matters: allocate the deduction proportionally across lines instead of greedily.
Type Parameters
L
L extends object
Parameters
lines
readonly L[]
manualPaidByContractor
ReadonlyMap<string, number>
Returns
object
deductedByContractor
deductedByContractor:
Map<string,number>
lines
lines:
L[]
unappliedByContractor
unappliedByContractor:
Map<string,number>