How the Portugal iuc calculator is verified

Inputs

InputFieldType
Cilindrada (cm³)ccnumber
Emissões CO2 (g/km, WLTP)co2number
Ano da 1ª matrículaanoMatriculanumber
Gasóleogasoleoboolean
100% elétrico (isento)eletricoboolean

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)
Taxa de cilindradataxaCilindrada($c := cc; $round($c <= 1250 ? $const.cil1 : $c <= 1750 ? $const.cil2 : $c <= 2500 ? $const.cil3 : $const.cil4, 2))
Taxa de CO2taxaCo2($e := co2; $round($e <= 140 ? $const.co21 : $e <= 205 ? $const.co22 : $e <= 260 ? $const.co23 : $const.co24, 2))
Coeficiente do anocoeficiente($a := anoMatricula; $a <= 2007 ? 1.00 : $a = 2008 ? 1.05 : $a = 2009 ? 1.10 : 1.15)
Adicional de gasóleoadicionalGasoleo($c := cc; $round(gasoleo ? ($c <= 1250 ? $const.ad1 : $c <= 1750 ? $const.ad2 : $c <= 2500 ? $const.ad3 : $const.ad4) : 0, 2))
IUC anualiuc$round(eletrico ? 0 : (taxaCilindrada + taxaCo2) * coeficiente + adicionalGasoleo, 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
cil131.77
cil263.74
cil3127.35
cil4435.84
co2165.15
co2297.63
co23212.04
co24363.25
ad15.02
ad210.07
ad320.12
ad468.85

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 gasolina de 2019, 1.395 cm³, 109 g/km — o exemplo publicado

given cc1395
given co2109
given anoMatricula2019
given gasoleono
given eletricono
expect taxaCilindrada63.74
expect taxaCo265.15
expect coeficiente1.15
expect adicionalGasoleo0
expect iuc148.22

Case 2 — C2 o mesmo carro em gasóleo — soma o adicional de 10,07 EUR

given cc1395
given co2109
given anoMatricula2019
given gasoleoyes
given eletricono
expect adicionalGasoleo10.07
expect iuc158.29

Case 3 — C3 100% elétrico — isento de IUC

given cc0
given co20
given anoMatricula2024
given gasoleono
given eletricoyes
expect iuc0

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 Portugal iuc calculator

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