How the Germany car tax calculator is verified

Inputs

InputFieldType
Engine displacement (cm³)displacementnumber
CO₂ emissions (g/km)co2number
Diesel (otherwise petrol)dieselboolean

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)
Displacement UnitsdisplacementUnits$ceil(displacement / 100)
Displacement partdisplacementTax$round(displacementUnits * (diesel ? $const.dieselPer100 : $const.petrolPer100), 2)
CO₂ part (above 95 g/km)co2Tax($c := co2; $b1 := (($c < 115 ? $c : 115) - 95); $b1 := ($b1 > 0 ? $b1 : 0) * 2.00; $b2 := ($c > 115 ? (($c < 135 ? $c : 135) - 115) : 0) * 2.20; $b3 := ($c > 135 ? (($c < 155 ? $c : 155) - 135) : 0) * 2.50; $b4 := ($c > 155 ? (($c < 175 ? $c : 175) - 155) : 0) * 2.90; $b5 := ($c > 175 ? (($c < 195 ? $c : 195) - 175) : 0) * 3.40; $b6 := ($c > 195 ? ($c - 195) : 0) * 4.00; $round($b1 + $b2 + $b3 + $b4 + $b5 + $b6, 2))
Annual taxannualTax$round(displacementTax + co2Tax, 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
petrolPer1002
dieselPer1009.5
co2Free95

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 — C1 petrol 1,398 cm³, 122 g/km

given displacement1398
given co2122
given dieselno
expect displacementUnits14
expect displacementTax28
expect co2Tax55.4
expect annualTax83.4

Case 2 — C2 diesel 1,968 cm³, 145 g/km

given displacement1968
given co2145
given dieselyes
expect displacementUnits20
expect displacementTax190
expect co2Tax109
expect annualTax299

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

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