How the Canada take-home pay calculator is verified

Inputs

InputFieldType
Gross annual salary (CAD)grossAnnualnumber
Provinceprovincestring
Provincial rate if "Other" (e.g. 0.0805)customProvincialRatenumber

The formula

Each derived value below is computed by the Valem engine from the expression shown, in this order. Nothing else runs — there is no hidden code path.

Derived valueFieldFormula (JSONata)
Provincial rateprovincialRate($s := province; $s = 'ON' ? $const.rateON : $s = 'AB' ? $const.rateAB : $s = 'QC' ? $const.rateQC : $s = 'BC' ? $const.rateBC : customProvincialRate)
Federal taxfederalTax($t := grossAnnual; $g := (($t < 57375 ? $t : 57375) * 0.145) + (($t > 57375 ? (($t < 114750 ? $t : 114750) - 57375) : 0) * 0.205) + (($t > 114750 ? (($t < 177882 ? $t : 177882) - 114750) : 0) * 0.26) + (($t > 177882 ? (($t < 253414 ? $t : 253414) - 177882) : 0) * 0.29) + (($t > 253414 ? ($t - 253414) : 0) * 0.33); $n := $g - $const.bpa * 0.145; $round($n > 0 ? $n : 0, 2))
Provincial taxprovincialTax$round(grossAnnual * provincialRate, 2)
CPPcpp($base := (grossAnnual < 71300 ? grossAnnual : 71300) - 3500; $base := $base > 0 ? $base : 0; $cpp2 := grossAnnual > 71300 ? ((grossAnnual < 81200 ? grossAnnual : 81200) - 71300) : 0; $round($base * 0.0595 + $cpp2 * 0.04, 2))
EIei$round((grossAnnual < $const.eiCeiling ? grossAnnual : $const.eiCeiling) * $const.eiRate, 2)
Net / yearnetAnnual$round(grossAnnual - federalTax - provincialTax - cpp - ei, 2)
Net / monthnetMonthly$round(netAnnual / 12, 2)

Rates and thresholds

The expressions above read these as $const. They are the figures the annual refresh replaces, so they live as data rather than being written into the formulas — which is what makes a year-on-year change a one-line diff instead of an edit to arithmetic.

ConstantValue
bpa16129
eiRate0.0164
eiCeiling65700
rateON0.0805
rateAB0.08
rateQC0.14
rateBC0.0506

Test vectors (3)

Every case is executed against this model on each build, by the Java engine and independently by a JavaScript one. A mismatch of a single cent fails the build, so the page cannot ship advertising a figure the model no longer produces.

Case 1 — S1 70,000 CAD, Ontario

given grossAnnual70000
given provinceON
expect cpp3956.75
expect ei1077.48

Case 2 — S3 160,000 CAD

given grossAnnual160000
given provinceON
expect cpp4430.1
expect ei1077.48

Case 3 — S2 70,000 CAD in Alberta — the lowest provincial rate of the four

given grossAnnual70000
given provinceAB
expect provincialRate0.08
expect provincialTax5600

Sources

Check it yourself — and reuse it

The whole model as JSON — inputs, outputs, formulas, vectors and sources in one re-runnable document.

This model is published under CC BY 4.0: use it, adapt it, build on it, with attribution. The licence covers the model — the expression of each rule and the arrangement of the catalog. The rates and thresholds are law, and nobody licenses those; the sources above are where they come from.

← Back to the Canada take-home pay calculator

Built with Valem — a live, verifiable calculator you can fork and embed.