How the United Kingdom sole trader calculator is verified

Inputs

InputFieldType
Annual profit after expenses (GBP)annualProfitnumber

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)
Personal allowancepersonalAllowance$round($max([0, $const.fullAllowance - $max([0, annualProfit - $const.taperThreshold]) / 2]), 2)
Taxable IncometaxableIncome$round($max([0, annualProfit - personalAllowance]), 2)
Income taxincomeTax$round($const.basicRate * $min([taxableIncome, $const.basicBand]) + $const.higherRate * $max([0, $min([taxableIncome, $const.additionalThreshold]) - $const.basicBand]) + $const.additionalRate * $max([0, taxableIncome - $const.additionalThreshold]), 2)
Class 4 National Insuranceclass4NIC$round($const.nicMainRate * $max([0, $min([annualProfit, $const.nicUpperLimit]) - $const.nicLowerLimit]) + $const.nicUpperRate * $max([0, annualProfit - $const.nicUpperLimit]), 2)
Net income / yearnetIncome$round($max([0, annualProfit - incomeTax - class4NIC]), 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
fullAllowance12570
taperThreshold100000
basicBand37700
additionalThreshold125140
basicRate0.2
higherRate0.4
additionalRate0.45
nicLowerLimit12570
nicUpperLimit50270
nicMainRate0.06
nicUpperRate0.02

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 — 50,000 GBP profit — full allowance, basic rate only

given annualProfit50000
expect personalAllowance12570
expect taxableIncome37430
expect incomeTax7486
expect class4NIC2245.8
expect netIncome40268.2

Case 2 — 120,000 GBP profit — inside the allowance taper

given annualProfit120000
expect personalAllowance2570
expect taxableIncome117430
expect incomeTax39432
expect class4NIC3656.6
expect netIncome76911.4

Case 3 — 150,000 GBP profit — allowance fully tapered away, into the 45% band

given annualProfit150000
expect personalAllowance0
expect taxableIncome150000
expect incomeTax53703
expect class4NIC4256.6
expect netIncome92040.4

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 United Kingdom sole trader calculator

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