Functional Weave
Code in Rust

payroll.gross-to-net@1.0.0

README.md

2,519 bytes · view raw

# payroll.gross-to-net

Status: needs review by a qualified payroll professional before it is published.

One employee's payslip for one pay period. This capability contains no rates,
no thresholds and no rounding of its own: each line comes from the capability
that owns it, and what is left here is the order of operations, which is
where payslips usually go wrong.

1. **Tax period** from the pay date and frequency (`payroll.tax-period`).
2. **Pension** (`payroll.pension-auto-enrolment`), if the employee is in a
   scheme. Under a *net pay arrangement* the employee's contribution comes off
   pay before tax; under *relief at source* it is taken from net pay, already
   reduced by basic-rate relief, and taxable pay is untouched. Neither reduces
   National Insurance or student loan pay: only salary sacrifice does that,
   and salary sacrifice is a change to gross pay, so give the reduced gross.
3. **Income tax** on taxable pay (`payroll.income-tax`), cumulative or week
   1 / month 1 as the code says.
4. **National Insurance** on this period's gross (`payroll.national-insurance`),
   by the ordinary per-period method. Directors on the annual earnings period
   method should call `payroll.national-insurance` directly.
5. **Student loans** on this period's gross (`payroll.student-loan`). An
   employee with more than one undergraduate plan repays once, at the plan
   with the lowest threshold, which is the largest single-plan deduction; a
   postgraduate loan is repaid on top.
6. **Net pay** = gross - pension deduction - tax - employee NI - student loans.

A tax refund makes `tax` negative and increases net pay. Employer NI and the
employer pension contribution are reported but not deducted.

Out of scope: statutory payments (give them as part of gross), benefits in
kind, attachment of earnings orders, salary sacrifice arithmetic, and
deductions after net pay.

Sources: the rules are those of the capabilities listed above, each of which
cites its own. The order of deductions follows HMRC's "Employer further guide
to PAYE and NICs" (CWG2),
https://www.gov.uk/government/publications/cwg2-further-guide-to-paye-and-national-insurance-contributions,
and for student loans ("when the employee is on more than one plan, start
deductions for the plan with the lowest recovery threshold"; loans are worked
out on the same pay as secondary Class 1 NICs), HMRC's "Student loan and
postgraduate loan repayment guidance for employers",
https://www.gov.uk/guidance/special-rules-for-student-loans.