Functional Weave
Code in Python

payroll.pro-rata-salary@1.0.0

README.md

1,109 bytes · view raw

# payroll.pro-rata-salary

The salary due for a starter's or leaver's partial pay period, and for a
part-time worker, from the full-time salary for the period:

`pay = periodSalary x fteBasisPoints / 10000 x daysCounted / daysInPeriod`

computed exactly and rounded half-up to the penny once, at the end
(math.round-div), so the fraction of a penny is never rounded twice.

Two methods, because employers use both and they give different answers:

- **calendar-days** counts every day: 14 to 30 September is 17 of 30 days.
- **working-days** counts Monday to Friday, less the `holidays` supplied
  (dates.business-days-between): 14 to 30 September 2026 is 13 of 22 days.

Which one applies is a contractual choice, not a legal one. A third common
method, 1/260th or 1/365th of the annual salary per day, is the calendar or
working-days method applied to a year-long period: pass the annual salary with
the tax year as the period.

Both date ranges are inclusive. The employed range must sit inside the pay
period. A working-days period with no working days in it is an error, since the
fraction would be 0/0.