Functional Weave
Code in Rust

payroll.overtime@1.0.0

README.md

1,047 bytes · view raw

# payroll.overtime

Splits the minutes worked in a period across multiplier bands and prices each
band: with bands `[{0, 10000}, {2400, 15000}]` the first 40 hours are paid at
the basic rate and every minute after that at time and a half.

- Time is in whole **minutes**, so 37 hours 20 minutes is 2240, and no
  fractional hours ever reach the arithmetic.
- Each line is `hourlyRate x minutes x multiplier / 60`, rounded half-up to the
  penny once per line (math.round-div), and the total is the sum of the lines,
  so the payslip adds up to what it shows.
- Bands must start at 0 and ascend strictly; a band list that leaves the first
  minutes unpriced or overlaps itself is an error rather than a guess.
- Only bands the worker reached produce a line.

Overtime rules come from contracts, not statute, so the bands are the
caller's. Premiums by day (Sunday double time) are separate calls with that
day's minutes. Check the result with payroll.minimum-wage-check: overtime
premiums above the basic rate do not count towards the minimum wage.