How the Portugal salário líquido calculator is verified

Inputs

InputFieldType
Salário bruto anual (EUR)grossAnnualnumber

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)
Segurança Social (11%)ss$round(grossAnnual * $const.ssRate, 2)
Deductiondeductionss > $const.specificDeduction ? ss : $const.specificDeduction
Rendimento coletáveltaxable($b := grossAnnual - deduction; $round($b > 0 ? $b : 0, 2))
IRSirs($t := taxable; $round((($t < 8342 ? $t : 8342) * 0.125) + (($t > 8342 ? (($t < 12587 ? $t : 12587) - 8342) : 0) * 0.157) + (($t > 12587 ? (($t < 17838 ? $t : 17838) - 12587) : 0) * 0.212) + (($t > 17838 ? (($t < 23089 ? $t : 23089) - 17838) : 0) * 0.241) + (($t > 23089 ? (($t < 29397 ? $t : 29397) - 23089) : 0) * 0.311) + (($t > 29397 ? (($t < 43090 ? $t : 43090) - 29397) : 0) * 0.349) + (($t > 43090 ? (($t < 46566 ? $t : 46566) - 43090) : 0) * 0.431) + (($t > 46566 ? (($t < 86634 ? $t : 86634) - 46566) : 0) * 0.446) + (($t > 86634 ? ($t - 86634) : 0) * 0.48), 2))
Líquido / anonetAnnual$round(grossAnnual - ss - irs, 2)
Líquido / mês (14)netMonthly$round(netAnnual / 14, 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
ssRate0.11
specificDeduction4587.09

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 — S1 21,000 EUR (1,500 x 14) single

given grossAnnual21000
expect ss2310
expect deduction4587.09
expect taxable16412.91
expect irs2520.31

Case 2 — S3 60,000 EUR single

given grossAnnual60000
expect ss6600
expect deduction6600
expect taxable53400
expect irs15374.68

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 salário líquido calculator

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