How the Sweden fordonsskatt calculator is verified

Inputs

InputFieldType
CO₂ (g/km)co2number
Bilens ålder (år sedan den blev skattepliktig)ageYearsnumber

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)
I MalusiMalusageYears < $const.malusAr ? 1 : 0
Koldioxidbeloppco2Belopp($c := co2; iMalus = 1 ? $round((($c > $const.malusGrans1 ? (($c < $const.malusGrans2 ? $c : $const.malusGrans2) - $const.malusGrans1) : 0) * $const.malusSats1) + (($c > $const.malusGrans2 ? ($c - $const.malusGrans2) : 0) * $const.malusSats2), 2) : ($x := ($c - $const.standardGrans) * $const.standardSats; $round($x > 0 ? $x : 0, 2)))
Fordonsskatt / årtax$round($const.grundbelopp + co2Belopp, 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
grundbelopp360
malusGrans175
malusGrans2125
malusSats1107
malusSats2132
malusAr3
standardGrans111
standardSats22

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 — C1 100 g/km, nyare bil — det publicerade räkneexemplet

given co2100
given ageYears1
expect iMalus1
expect co2Belopp2675
expect tax3035

Case 2 — C2 150 g/km under malusperioden — båda satserna

given co2150
given ageYears1
expect co2Belopp8650
expect tax9010

Case 3 — C3 samma bil efter malusperioden — standardsatsen

given co2150
given ageYears5
expect iMalus0
expect co2Belopp858
expect tax1218

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 Sweden fordonsskatt calculator

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