Skip to content

Commit 24f3e9e

Browse files
authored
Merge pull request #1766 from PolicyEngine/codex/fix-class4-annual-maximum
Fix Class 4 NI annual maximum rate factor
2 parents 52d111b + ef165df commit 24f3e9e

3 files changed

Lines changed: 28 additions & 1 deletion

File tree

changelog.d/1765.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Correct the Class 4 National Insurance annual maximum calculation to use the current main Class 4 rate factor.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import pytest
2+
3+
from policyengine_uk import Simulation
4+
5+
6+
def test_class_4_annual_maximum_uses_current_main_rate_factor():
7+
year = 2026
8+
monthly_primary_class_1 = {f"{year}-{month:02d}": 500 for month in range(1, 13)}
9+
sim = Simulation(
10+
situation={
11+
"people": {
12+
"person": {
13+
"age": {year: 40},
14+
"self_employment_income": {year: 100_000},
15+
"ni_class_1_employee_primary": monthly_primary_class_1,
16+
}
17+
},
18+
"benunits": {"benunit": {"members": ["person"]}},
19+
"households": {"household": {"members": ["person"]}},
20+
}
21+
)
22+
23+
assert sim.calculate("ni_class_4_maximum", year)[0] == pytest.approx(
24+
46_484,
25+
abs=0.01,
26+
)

policyengine_uk/variables/gov/hmrc/national_insurance/class_4/ni_class_4_maximum.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def formula(person, period, parameters):
3030
case_1 = (step_4 >= 0) & (step_4 > other_aggregate_contributions)
3131
case_2 = (step_4 >= 0) & (step_4 <= other_aggregate_contributions)
3232
case_3 = step_4 < 0
33-
step_5 = step_4 * 100 / 9
33+
step_5 = step_4 / main_rate
3434
profits = person("self_employment_income", period)
3535
step_6 = lpl - min_(upl, profits)
3636
step_7 = max_(0, step_6 - step_5)

0 commit comments

Comments
 (0)