Skip to content

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.

PackModuleCoversCurrency, tax year
Sri Lankacountry-lkEPF, ETF, APIT tables 01, 02, 03 and 05, gratuity, employer registrationLKR, from 1 April
Canadacountry-caCPP, CPP2, EI, federal and provincial tax (T4127 option 1), Québec QPP, QPIP and tax, CRA and Revenu Québec registrationCAD, 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.toml lists 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_to on 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 ​

  1. A payroll accountant qualified in the country reviews each rule set against its sources, with an engineer to run the commands.
  2. The reviewed sets are added to rules/rules.lock. The lock is append-only, and CI checks it against the base branch.
  3. 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 ​

  1. Create modules/country-<code> with its rule sets, sources and both test suites.
  2. Implement CountryPack: its id, its tax year start and calculate for the statutory lines.
  3. Install it in orbit behind a cargo feature, as reviewed() only.
  4. Add its settings (employer registrations) and update this page and the payroll guide.

Orbit by SkySync Tech. Licensed under AGPL-3.0.