diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a56b9b83..e302f772f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [2.14.0] - 2024-10-28 12:09:01 + +### Fixed + +- Bugs affecting household app calculations. + ## [2.13.2] - 2024-10-28 10:46:29 ### Fixed @@ -1573,6 +1579,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 +[2.14.0]: https://github.com/PolicyEngine/openfisca-uk/compare/2.13.2...2.14.0 [2.13.2]: https://github.com/PolicyEngine/openfisca-uk/compare/2.13.1...2.13.2 [2.13.1]: https://github.com/PolicyEngine/openfisca-uk/compare/2.13.0...2.13.1 [2.13.0]: https://github.com/PolicyEngine/openfisca-uk/compare/2.12.0...2.13.0 diff --git a/changelog.yaml b/changelog.yaml index cc39a6a0a..484e02314 100644 --- a/changelog.yaml +++ b/changelog.yaml @@ -1320,3 +1320,8 @@ fixed: - Threshold freeze for ST extended to 2027. date: 2024-10-28 10:46:29 +- bump: minor + changes: + fixed: + - Bugs affecting household app calculations. + date: 2024-10-28 12:09:01 diff --git a/policyengine_uk/parameters/gov/hmrc/national_insurance/class_1/rates/employer.yaml b/policyengine_uk/parameters/gov/hmrc/national_insurance/class_1/rates/employer.yaml index 4a0083b1e..c3b9208bc 100644 --- a/policyengine_uk/parameters/gov/hmrc/national_insurance/class_1/rates/employer.yaml +++ b/policyengine_uk/parameters/gov/hmrc/national_insurance/class_1/rates/employer.yaml @@ -3,7 +3,7 @@ description: National Insurance contribution rate by employers on earnings above metadata: label: NI Employer rate propagate_metadata_to_children: true + unit: /1 reference: https://assets.publishing.service.gov.uk/government/uploads/system/uploads/attachment_data/file/882271/Table-a4.pdf - unit: marginal-rate values: 2015-06-01: 0.138 diff --git a/policyengine_uk/variables/contrib/labour/private_school_vat.py b/policyengine_uk/variables/contrib/labour/private_school_vat.py index fae34a3fb..755cfb699 100644 --- a/policyengine_uk/variables/contrib/labour/private_school_vat.py +++ b/policyengine_uk/variables/contrib/labour/private_school_vat.py @@ -9,6 +9,8 @@ class attends_private_school(Variable): value_type = bool def formula(person, period, parameters): + if not hasattr(person.simulation, "dataset"): + return 0 household = person.household # To ensure that our model matches # total number of students actually enrolled @@ -37,6 +39,9 @@ def formula(person, period, parameters): household_weight = household("household_weight", period) weighted_income = MicroSeries(net_income, weights=household_weight) + if household_weight.sum() < 1e6: + return 0 + percentile = np.zeros_like(weighted_income).astype(numpy.int64) mask = household_weight > 0 @@ -60,7 +65,9 @@ def formula(person, period, parameters): * is_child ) - return random(person) < p_attends_private_school + value = random(person) < p_attends_private_school + + return value class private_school_vat(Variable): diff --git a/policyengine_uk/variables/contrib/policyengine/employer_ni/employer_ni_fixed_employer_cost_change.py b/policyengine_uk/variables/contrib/policyengine/employer_ni/employer_ni_fixed_employer_cost_change.py index 784842b83..43c271c28 100644 --- a/policyengine_uk/variables/contrib/policyengine/employer_ni/employer_ni_fixed_employer_cost_change.py +++ b/policyengine_uk/variables/contrib/policyengine/employer_ni/employer_ni_fixed_employer_cost_change.py @@ -159,12 +159,15 @@ def formula(person, period, parameters): total_consumption = (consumption * person_weight).sum() share_of_total_consumption = consumption / total_consumption - return ( + value = ( amount_paid_by_employers * share_of_total_consumption * consumer_incidence ) + if total_consumption == 0: + return 0 + class employer_ni_response_capital_incidence(Variable): label = "capital response to employer NI reform" @@ -199,12 +202,15 @@ def formula(person, period, parameters): total_wealth = (wealth * person_weight).sum() share_of_total_wealth = wealth / total_wealth - return ( + value = ( amount_paid_by_employers * share_of_total_wealth * capital_incidence ) + if total_wealth == 0: + return 0 + class employer_ni_fixed_employer_cost_change(Variable): label = "employer NI reform incidence" diff --git a/setup.py b/setup.py index bbfd87ac0..ef3e9969a 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ setup( name="PolicyEngine-UK", - version="2.13.2", + version="2.14.0", author="PolicyEngine", author_email="nikhil@policyengine.org", classifiers=[