Skip to content
Draft
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
2 changes: 1 addition & 1 deletion changelog_entry.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
- bump: patch
changes:
fixed:
- Parameterize age 35 threshold in LHA shared accommodation rules
- Basic state pension calculation.
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
- name: Basic state pension calculation with normal parameters
period: 2021
input:
people:
person1:
state_pension_reported: 5000
state_pension_type: BASIC
age: 70
output:
basic_state_pension: 5000 # Should be capped at the minimum of reported and maximum

- name: Basic state pension caps at maximum when reported exceeds maximum
period: 2021
input:
people:
person1:
state_pension_reported: 10000 # Higher than maximum
state_pension_type: BASIC
age: 70
output:
basic_state_pension: 7155.2 # Should be capped at maximum (137.60 * 52)

- name: Non-basic state pension not affected by basic pension maximum
period: 2021
input:
people:
person1:
state_pension_reported: 5000
state_pension_type: NEW # Not basic pension
age: 70
output:
basic_state_pension: 5000 # Should not be affected by basic pension maximum

- name: Basic state pension should be zero when maximum is zero
period: 2021
input:
gov.dwp.state_pension.basic_state_pension.amount: 0
people:
person1:
state_pension_reported: 5000
state_pension_type: BASIC
age: 70
output:
basic_state_pension: 0
28 changes: 20 additions & 8 deletions policyengine_uk/variables/gov/dwp/basic_state_pension.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,32 @@ class basic_state_pension(Variable):

def formula(person, period, parameters):
simulation = person.simulation
if simulation.dataset is None:
return 0
has_dataset = simulation.dataset is not None

data_year = simulation.dataset.time_period if has_dataset else period

reported = where(
has_dataset,
person("state_pension_reported", data_year) / WEEKS_IN_YEAR,
person("state_pension_reported", period) / WEEKS_IN_YEAR,
)

data_year = simulation.dataset.time_period
reported = person("state_pension_reported", data_year) / WEEKS_IN_YEAR
type = person("state_pension_type", period)
maximum_basic_sp = parameters(
data_year
).gov.dwp.state_pension.basic_state_pension.amount
amount_in_data_year = where(
type == type.possible_values.BASIC,
min_(reported, maximum_basic_sp),
0,
reported,
)
triple_lock = parameters.gov.economic_assumptions.indices.triple_lock
uprating_since_data_year = triple_lock(period) / triple_lock(data_year)
return amount_in_data_year * uprating_since_data_year * WEEKS_IN_YEAR
uprating_factor = where(
has_dataset,
parameters.gov.economic_assumptions.yoy_growth.triple_lock(period)
/ parameters.gov.economic_assumptions.yoy_growth.triple_lock(
data_year
),
1,
)

return amount_in_data_year * uprating_factor * WEEKS_IN_YEAR
Loading