How the Denmark selvstændig calculator is verified

Inputs

InputFieldType
Annual surplus (DKK)annualSurplusnumber

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)
AM-bidrag (8%)amBidrag$round(annualSurplus * $const.amRate, 2)
After Am BidragafterAmBidrag$round(annualSurplus - amBidrag, 2)
Bottom + municipal + health taxbaseTax$round($const.baseRate * $max([0, afterAmBidrag - $const.personalAllowance]), 2)
Intermediate / top / top-top taxbracketTax($a := afterAmBidrag; $round($const.mellemRate * $max([0, $min([$a, $const.topStart]) - $const.mellemStart]) + $const.topRate * $max([0, $min([$a, $const.topTopStart]) - $const.topStart]) + $const.topTopRate * $max([0, $a - $const.topTopStart]), 2))
Net income / yearnetIncome$round($max([0, annualSurplus - amBidrag - baseTax - bracketTax]), 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
amRate0.08
personalAllowance54100
baseRate0.34
mellemStart641200
topStart777900
topTopStart2592700
mellemRate0.075
topRate0.075
topTopRate0.05

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 — 600,000 DKK surplus — a typical full-time freelancer

given annualSurplus600000
expect amBidrag48000
expect afterAmBidrag552000
expect baseTax169286
expect bracketTax0
expect netIncome382714

Case 2 — 250,000 DKK — part-time

given annualSurplus250000
expect amBidrag20000
expect afterAmBidrag230000
expect baseTax59806
expect bracketTax0
expect netIncome170194

Case 3 — 1,200,000 DKK — into the top bracket

given annualSurplus1200000
expect amBidrag96000
expect afterAmBidrag1104000
expect baseTax356966
expect bracketTax34710
expect netIncome712324

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 Denmark selvstændig calculator

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