Appearance
Country packs
Payroll never names a country. Statutory rules come from a country pack, a module that plugs into payroll through orbit_payroll::calc::CountryPack. A company picks its pack in payroll settings.
| Pack | Module | Covers | Currency, tax year |
|---|---|---|---|
| Sri Lanka | country-lk | EPF, ETF, APIT tables 01, 02, 03 and 05, gratuity, employer registration | LKR, from 1 April |
| Canada | country-ca | CPP, CPP2, EI, federal and provincial tax (T4127 option 1), Québec QPP, QPIP and tax, CRA and Revenu Québec registration | CAD, from 1 January |
Drafts until reviewed
Every rule set in both packs is a draft. The production build installs only reviewed rules, so a company on a pack can't calculate a run (statutory_rules_unreviewed) until a qualified payroll accountant has reviewed the rules and they are locked in rules/rules.lock.
Rule sets
- Rules live in
modules/country-*/rules/<id>/<valid_from>/: Rhai scripts plus TOML tables, effective-dated (valid_from,valid_to). A run uses the set in force for its period. - Every rate cites its source. Each
rules.tomllists its[[sources]], and each script's header repeats them; the engine refuses a script whose header misses one. - Never edit a past rule set. Publish a new version and set
valid_toon the old one. - Rhai runs sandboxed: no I/O, operation limits and timeouts.
Traces
Every calculated line stores a trace: rule id, version, inputs and result. Payslips and Explain read the trace; nothing is recalculated for display.
Tests
Each statutory rule has two independent suites, and both must pass:
- Golden vectors written from the official tables.
- Property tests written with the implementation.
Review and lock
- A payroll accountant qualified in the country reviews each rule set against its sources, with an engineer to run the commands.
- The reviewed sets are added to
rules/rules.lock. The lock is append-only, and CI checks it against the base branch. - From then on the pack calculates runs whose period those sets cover.
Details and the open questions per pack: modules/country-lk/README.md, modules/country-ca/README.md.
Adding a country
- Create
modules/country-<code>with its rule sets, sources and both test suites. - Implement
CountryPack: its id, its tax year start andcalculatefor the statutory lines. - Install it in
orbitbehind a cargo feature, asreviewed()only. - Add its settings (employer registrations) and update this page and the payroll guide.