Audience: Backend engineers, DBAs, integration engineers, anyone who needs to reason about how payroll is computed, stored, and orchestrated. This is the developer-facing companion to business.md.

Source of truth. Every algorithm and behaviour described here was derived from reading the actual code:

Where the code is the source of truth and a fact in here looks wrong, the code wins — please file a doc-fix. Items still requiring product or operational confirmation are marked ⚠️ VERIFY.


Table of Contents

  1. Architectural shape — where things live
  2. The three databases
  3. Core entity model and ER picture
  4. The "Clone columns" pattern
  5. The C#/SQL boundary — orchestration vs computation
  6. SQL functions glossary
  7. Payroll lifecycle and status machine
  8. PreparePayroll end-to-end
  9. SubmitPayroll end-to-end
  10. Pro-ration math
  11. Tax math — PAYE and WHT
  12. Combined vs Individual tax mode (the algorithm)
  13. Net-to-Gross algorithm
  14. Statutory benefits computation
  15. Tax reliefs application
  16. Anniversary / Pre-Anniversary remittance evaluation