How the Canada gst/hst calculator is verified

Inputs

InputFieldType
Amountamountnumber
Directiondirectionstring
Where is the supply madecategorystring
B2B reverse charge appliesreverseChargeboolean

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)
Rateratecategory = 'ontario' ? $const.hstOntario : category = 'novaScotia' ? $const.hstNovaScotia : category = 'participating' ? $const.hstParticipating : $const.standardRate
Effective RateeffectiveRatereverseCharge ? 0 : rate
Net AmountnetAmountdirection = 'remove' ? $round(amount / (1 + effectiveRate), 2) : $round(amount, 2)
Vat AmountvatAmount$round(netAmount * effectiveRate, 2)
Gross AmountgrossAmount$round(netAmount + vatAmount, 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
standardRate0.05
hstOntario0.13
hstNovaScotia0.14
hstParticipating0.15

Test vectors (6)

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 100.00 CAD net in a non-participating province: 5% GST

given amount100
given directionadd
given categorystandard
given reverseChargeno
expect vatAmount5
expect grossAmount105
expect netAmount100

Case 2 — S2 100.00 CAD in Ontario: 13% HST

given amount100
given directionadd
given categoryontario
given reverseChargeno
expect vatAmount13
expect grossAmount113

Case 3 — S3 100.00 CAD in Nova Scotia: 14% HST since 1 April 2025

given amount100
given directionadd
given categorynovaScotia
given reverseChargeno
expect rate0.14
expect vatAmount14
expect grossAmount114

Case 4 — S4 100.00 CAD in another participating province: 15% HST

given amount100
given directionadd
given categoryparticipating
given reverseChargeno
expect vatAmount15
expect grossAmount115

Case 5 — S5 113.00 CAD gross in Ontario back to net

given amount113
given directionremove
given categoryontario
given reverseChargeno
expect netAmount100
expect vatAmount13

Case 6 — S6 reverse charge: the supplier charges no GST/HST

given amount100
given directionadd
given categoryontario
given reverseChargeyes
expect vatAmount0
expect grossAmount100

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 gst/hst calculator

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