Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/1765.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Correct the Class 4 National Insurance annual maximum calculation to use the current main Class 4 rate factor.
26 changes: 26 additions & 0 deletions policyengine_uk/tests/test_ni_class_4_maximum.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import pytest

from policyengine_uk import Simulation


def test_class_4_annual_maximum_uses_current_main_rate_factor():
year = 2026
monthly_primary_class_1 = {f"{year}-{month:02d}": 500 for month in range(1, 13)}
sim = Simulation(
situation={
"people": {
"person": {
"age": {year: 40},
"self_employment_income": {year: 100_000},
"ni_class_1_employee_primary": monthly_primary_class_1,
}
},
"benunits": {"benunit": {"members": ["person"]}},
"households": {"household": {"members": ["person"]}},
}
)

assert sim.calculate("ni_class_4_maximum", year)[0] == pytest.approx(
46_484,
abs=0.01,
)
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def formula(person, period, parameters):
case_1 = (step_4 >= 0) & (step_4 > other_aggregate_contributions)
case_2 = (step_4 >= 0) & (step_4 <= other_aggregate_contributions)
case_3 = step_4 < 0
step_5 = step_4 * 100 / 9
step_5 = step_4 / main_rate
profits = person("self_employment_income", period)
step_6 = lpl - min_(upl, profits)
step_7 = max_(0, step_6 - step_5)
Expand Down