From fc73dd36e68cf3ab07b2f9426a272ce3a0bf1fd5 Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Thu, 4 Jun 2026 22:02:02 +0100 Subject: [PATCH] Fix UC housing costs element floor --- .../uc_housing_costs_element.yaml | 19 +++++++++++++++++++ .../uc_housing_costs_element.py | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/policyengine_uk/tests/policy/baseline/finance/benefit/family/universal_credit/housing_costs_element/uc_housing_costs_element.yaml b/policyengine_uk/tests/policy/baseline/finance/benefit/family/universal_credit/housing_costs_element/uc_housing_costs_element.yaml index 42b0943b2..22676b593 100644 --- a/policyengine_uk/tests/policy/baseline/finance/benefit/family/universal_credit/housing_costs_element/uc_housing_costs_element.yaml +++ b/policyengine_uk/tests/policy/baseline/finance/benefit/family/universal_credit/housing_costs_element/uc_housing_costs_element.yaml @@ -103,3 +103,22 @@ members: person output: uc_housing_costs_element: 5_000 - 10 * 52 + +- name: Rented privately, non-dependent deductions exceed housing costs + period: 2022 + absolute_error_margin: 0 + input: + people: + person: {} + benunits: + benunit: + benunit_rent: 1_000 + uc_non_dep_deductions: 2_000 + LHA_cap: 5_000 + members: person + households: + household: + tenure_type: RENT_PRIVATELY + members: person + output: + uc_housing_costs_element: 0 diff --git a/policyengine_uk/variables/gov/dwp/universal_credit/housing_costs_element/uc_housing_costs_element.py b/policyengine_uk/variables/gov/dwp/universal_credit/housing_costs_element/uc_housing_costs_element.py index 1bba4ddef..d205bd918 100644 --- a/policyengine_uk/variables/gov/dwp/universal_credit/housing_costs_element/uc_housing_costs_element.py +++ b/policyengine_uk/variables/gov/dwp/universal_credit/housing_costs_element/uc_housing_costs_element.py @@ -26,4 +26,4 @@ def formula(benunit, period, parameters): default=0, ) non_dependent_deductions = benunit("uc_non_dep_deductions", period) - return max_housing_costs - non_dependent_deductions + return max_(max_housing_costs - non_dependent_deductions, 0)