How the Estonia car tax calculator is verified

Inputs

InputFieldType
CO₂ emissions (g/km, WLTP)co2number
Gross mass (kg)massnumber

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)
CO₂ over 117 g/kmco2Over($x := co2 - $const.co2Free; $round($x > 0 ? $x : 0, 2))
Mass OvermassOver($x := mass - $const.massFree; $round($x > 0 ? $x : 0, 2))
Annual CO₂ componentannualCo2$round($const.annualCo2Rate * co2Over, 2)
Annual weight componentannualWeight$round($const.annualMassRate * massOver, 2)
Annual taxannualTax$round($const.annualBase + annualCo2 + annualWeight, 2)
Reg Co2regCo2$round($const.regCo2Rate * co2Over, 2)
Registration (one-time)registrationTax$round($const.regBase + regCo2, 2)
First-year totalfirstYearTotal$round(annualTax + registrationTax, 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
co2Free117
massFree2000
annualBase50
annualCo2Rate3
annualMassRate0.2
regBase300
regCo2Rate5

Test vectors (2)

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 — 150 g/km, 1800 kg

given co2150
given mass1800
expect co2Over33
expect annualTax149
expect registrationTax465
expect firstYearTotal614

Case 2 — 95 g/km (below CO2 threshold), 2500 kg heavy

given co295
given mass2500
expect co2Over0
expect annualWeight100
expect annualTax150
expect registrationTax300
expect firstYearTotal450

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 Estonia car tax calculator

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