From e7a06e2d5f792919639c5017033007b9702dd3ea Mon Sep 17 00:00:00 2001 From: Mauko Quiroga Date: Sun, 4 Dec 2022 21:59:25 +0100 Subject: [PATCH 1/4] Add Peta's case --- .../accommodation_supplement/cutout.yaml | 2 +- .../2018/_benefit_me.yaml | 37 +++++++++++++++++++ .../accommodation_supplement/2018/base.yaml | 30 +++++++-------- .../accommodation_supplement/area.py | 3 +- .../jobseeker_support/jobseeker_support.py | 1 + .../sole_parent_support_benefit.py | 3 +- .../variables/demographics/housing.py | 4 +- 7 files changed, 61 insertions(+), 19 deletions(-) create mode 100644 openfisca_aotearoa/tests/social_security/accommodation_supplement/2018/_benefit_me.yaml diff --git a/openfisca_aotearoa/parameters/social_security/accommodation_supplement/cutout.yaml b/openfisca_aotearoa/parameters/social_security/accommodation_supplement/cutout.yaml index f6d9097f..9b676a16 100644 --- a/openfisca_aotearoa/parameters/social_security/accommodation_supplement/cutout.yaml +++ b/openfisca_aotearoa/parameters/social_security/accommodation_supplement/cutout.yaml @@ -146,7 +146,7 @@ section_5: section_6: description: > - o any other person whose accommodation costs are the sum of payments + To any other person whose accommodation costs are the sum of payments required under any mortgage security, and other payments that the chief executive is satisfied are reasonably required to be made in respect of the person’s home. diff --git a/openfisca_aotearoa/tests/social_security/accommodation_supplement/2018/_benefit_me.yaml b/openfisca_aotearoa/tests/social_security/accommodation_supplement/2018/_benefit_me.yaml new file mode 100644 index 00000000..63f5dfb9 --- /dev/null +++ b/openfisca_aotearoa/tests/social_security/accommodation_supplement/2018/_benefit_me.yaml @@ -0,0 +1,37 @@ +- name: > + BenefitMe + Peta's Story + period: 2022-12-05 + relative_error_margin: 0.001 + input: + persons: + Peta: + age: + day:2022-01-01:365: 32 + social_security__in_a_relationship: + week:2022-W01:52: false + accommodation_costs: + week:2022-W01:52: 350 + accommodation_type: + week:2022-W01:52: rent + accommodation_supplement__area_of_residence: + week:2022-W01:52: area_2 + family_tax_credit__eligible: + 2022: true + jobseeker_support__entitled: + week:2022-W01:52: true + Anahera: + age: + day:2022-01-01:365: 5 + social_security__dependent_child: + week:2022-W01:52: true + family_tax_credit__dependent_child: + 2022: true + family: + principal: Peta + children: [Anahera] + output: + accommodation_supplement: + 2022-W49: [145.54, 0] + family_tax_credit: + 2022: [6623.80, 0] diff --git a/openfisca_aotearoa/tests/social_security/accommodation_supplement/2018/base.yaml b/openfisca_aotearoa/tests/social_security/accommodation_supplement/2018/base.yaml index f81c8f8a..cc7eacf3 100644 --- a/openfisca_aotearoa/tests/social_security/accommodation_supplement/2018/base.yaml +++ b/openfisca_aotearoa/tests/social_security/accommodation_supplement/2018/base.yaml @@ -50,7 +50,7 @@ 2022-W02: true 2022-W03: false family_tax_credit__dependent_child: - 2022: 33 + 2022: .33 Srko: date_of_birth: ETERNITY: 2006-01-11 @@ -59,7 +59,7 @@ 2022-W02: true 2022-W03: false family_tax_credit__dependent_child: - 2022: 33 + 2022: .33 Ash: date_of_birth: ETERNITY: 2006-01-12 @@ -68,7 +68,7 @@ 2022-W02: true 2022-W03: true family_tax_credit__dependent_child: - 2022: 33 + 2022: .33 family: principal: Vranda children: [Piedad, Srko, Ash] @@ -154,7 +154,7 @@ 2022-W02: true 2022-W03: false family_tax_credit__dependent_child: - 2022: 33 + 2022: .33 Srko: date_of_birth: ETERNITY: 2006-01-11 @@ -163,7 +163,7 @@ 2022-W02: true 2022-W03: false family_tax_credit__dependent_child: - 2022: 33 + 2022: .33 Ash: date_of_birth: ETERNITY: 2006-01-12 @@ -172,7 +172,7 @@ 2022-W02: true 2022-W03: true family_tax_credit__dependent_child: - 2022: 33 + 2022: .33 family: principal: Vranda children: [Piedad, Srko, Ash] @@ -214,7 +214,7 @@ 2022-W02: true 2022-W03: false family_tax_credit__dependent_child: - 2022: 33 + 2022: .33 Srko: date_of_birth: ETERNITY: 2006-01-11 @@ -223,7 +223,7 @@ 2022-W02: true 2022-W03: false family_tax_credit__dependent_child: - 2022: 33 + 2022: .33 Ash: date_of_birth: ETERNITY: 2006-01-12 @@ -232,7 +232,7 @@ 2022-W02: true 2022-W03: true family_tax_credit__dependent_child: - 2022: 33 + 2022: .33 family: principal: Vranda children: [Piedad, Srko, Ash] @@ -314,7 +314,7 @@ 2022-W02: true 2022-W03: false family_tax_credit__dependent_child: - 2022: 33 + 2022: .33 Srko: date_of_birth: ETERNITY: 2006-01-11 @@ -323,7 +323,7 @@ 2022-W02: true 2022-W03: false family_tax_credit__dependent_child: - 2022: 33 + 2022: .33 Ash: date_of_birth: ETERNITY: 2006-01-12 @@ -332,7 +332,7 @@ 2022-W02: true 2022-W03: true family_tax_credit__dependent_child: - 2022: 33 + 2022: .33 family: principal: Vranda children: [Piedad, Srko, Ash] @@ -394,7 +394,7 @@ 2022-W02: true 2022-W03: false family_tax_credit__dependent_child: - 2022: 33 + 2022: .33 Srko: date_of_birth: ETERNITY: 2006-01-11 @@ -403,7 +403,7 @@ 2022-W02: true 2022-W03: false family_tax_credit__dependent_child: - 2022: 33 + 2022: .33 Ash: date_of_birth: ETERNITY: 2006-01-12 @@ -412,7 +412,7 @@ 2022-W02: true 2022-W03: true family_tax_credit__dependent_child: - 2022: 33 + 2022: .33 family: principal: Vranda partners: [Bob] diff --git a/openfisca_aotearoa/variables/acts/social_security/accommodation_supplement/area.py b/openfisca_aotearoa/variables/acts/social_security/accommodation_supplement/area.py index d7e1aa89..40889ad0 100644 --- a/openfisca_aotearoa/variables/acts/social_security/accommodation_supplement/area.py +++ b/openfisca_aotearoa/variables/acts/social_security/accommodation_supplement/area.py @@ -5,7 +5,7 @@ import numpy import pandas -from openfisca_core import indexed_enums, periods, variables +from openfisca_core import holders, indexed_enums, periods, variables import openfisca_aotearoa from openfisca_aotearoa import entities @@ -38,6 +38,7 @@ class accommodation_supplement__area_of_residence(variables.Variable): possible_values = AccommodationSupplement__AreaOfResidence default_value = AccommodationSupplement__AreaOfResidence.unknown definition_period = periods.DateUnit.WEEK + set_input = holders.set_input_dispatch_by_period def formula_2018_11_26(people, period, _params): area_of_residence = AccommodationSupplement__AreaOfResidence diff --git a/openfisca_aotearoa/variables/acts/social_security/jobseeker_support/jobseeker_support.py b/openfisca_aotearoa/variables/acts/social_security/jobseeker_support/jobseeker_support.py index 2a49154c..75bcdef5 100644 --- a/openfisca_aotearoa/variables/acts/social_security/jobseeker_support/jobseeker_support.py +++ b/openfisca_aotearoa/variables/acts/social_security/jobseeker_support/jobseeker_support.py @@ -38,6 +38,7 @@ class jobseeker_support__entitled(variables.Variable): definition_period = periods.WEEK label = "Jobseeker Support eligibility and amount" reference = "https://www.legislation.govt.nz/act/public/2018/0032/latest/whole.html#DLM6783144", "http://legislation.govt.nz/act/public/1964/0136/latest/DLM5478527.html" + set_input = holders.set_input_dispatch_by_period # Old Job Seeker formula for 1964 Act, rewritten to show gaps def formula_2013_04_17(persons, period, parameters): diff --git a/openfisca_aotearoa/variables/acts/social_security/sole_parent_support/sole_parent_support_benefit.py b/openfisca_aotearoa/variables/acts/social_security/sole_parent_support/sole_parent_support_benefit.py index 4d123e01..a3347f04 100644 --- a/openfisca_aotearoa/variables/acts/social_security/sole_parent_support/sole_parent_support_benefit.py +++ b/openfisca_aotearoa/variables/acts/social_security/sole_parent_support/sole_parent_support_benefit.py @@ -6,7 +6,7 @@ # # For more information on OpenFisca's available modules: # https://openfisca.org/doc/openfisca-python-api/index.html -from openfisca_core import periods, variables +from openfisca_core import holders, periods, variables # We import the required `entities` corresponding to our formulas. # @@ -24,6 +24,7 @@ class sole_parent_support__benefit(variables.Variable): definition_period = periods.WEEK label = "The final net benefit entitlement" reference = "https://www.legislation.govt.nz/act/public/2018/0032/latest/DLM6784854.html" + set_input = holders.set_input_dispatch_by_period def formula_2018_11_26(people, period, parameters): return people("sole_parent_support__entitled", period) * numpy.clip(people("sole_parent_support__base", period) - people("sole_parent_support__reduction", period), 0, people("sole_parent_support__base", period)) diff --git a/openfisca_aotearoa/variables/demographics/housing.py b/openfisca_aotearoa/variables/demographics/housing.py index cd1a32eb..85c2dcc7 100644 --- a/openfisca_aotearoa/variables/demographics/housing.py +++ b/openfisca_aotearoa/variables/demographics/housing.py @@ -1,6 +1,6 @@ """TODO: Add missing doctring.""" -from openfisca_core import indexed_enums, periods, variables +from openfisca_core import holders, indexed_enums, periods, variables from openfisca_aotearoa import entities @@ -24,6 +24,7 @@ class accommodation_type(variables.Variable): possible_values = AccommodationType default_value = AccommodationType.unknown definition_period = periods.DateUnit.WEEK + set_input = holders.set_input_dispatch_by_period class accommodation_costs(variables.Variable): @@ -34,3 +35,4 @@ class accommodation_costs(variables.Variable): value_type = float default_value = 0 definition_period = periods.DateUnit.WEEK + set_input = holders.set_input_dispatch_by_period From e7bb4b4052b5a847713a55b07f2cb0f509d23b09 Mon Sep 17 00:00:00 2001 From: Mauko Quiroga Date: Sun, 4 Dec 2022 22:03:23 +0100 Subject: [PATCH 2/4] Bump version --- CHANGELOG.md | 10 ++++++++ .../2018/_benefit_me.yaml | 25 +++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 444b4318..fe432ee6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,16 @@ * Other Changes: - `tests/social_security/sole_parent_support/sole_parent_support__benefit.yaml figure fixed for 2022/23` +## 20.1.0 - [48](https://github.com/digitalaotearoa/openfisca-aotearoa/pull/48) + +* Test case. +* Impacted periods: none. +* Impacted areas: `tests/accommodation_supplement` +* Details: + - Add Peta's story + - Add Kai's story +>>>>>>> 6f04876 (Bump version) + # 20.0.0 - [43](https://github.com/govzeroaotearoa/openfisca-aotearoa/pull/43) * Added variables: diff --git a/openfisca_aotearoa/tests/social_security/accommodation_supplement/2018/_benefit_me.yaml b/openfisca_aotearoa/tests/social_security/accommodation_supplement/2018/_benefit_me.yaml index 63f5dfb9..80ee26f4 100644 --- a/openfisca_aotearoa/tests/social_security/accommodation_supplement/2018/_benefit_me.yaml +++ b/openfisca_aotearoa/tests/social_security/accommodation_supplement/2018/_benefit_me.yaml @@ -35,3 +35,28 @@ 2022-W49: [145.54, 0] family_tax_credit: 2022: [6623.80, 0] + + +- name: > + BenefitMe + Kai's Story + period: 2022-12-05 + relative_error_margin: 0.001 + input: + persons: + Kai: + age: + day:2022-01-01:365: 23 + accommodation_costs: + week:2022-W01:52: 350 + accommodation_type: + week:2022-W01:52: board + accommodation_supplement__area_of_residence: + week:2022-W01:52: area_2 + accommodation_supplement__cash_assets: + 2022-W49: 800 + jobseeker_support__entitled: + week:2022-W01:52: true + output: + accommodation_supplement: + 2022-W49: 105.00 From a8b2bee7389dfd438519bb520dd0d35f1c546338 Mon Sep 17 00:00:00 2001 From: Mauko Quiroga Date: Tue, 6 Dec 2022 00:40:05 +0100 Subject: [PATCH 3/4] Fix tax credit example --- .../2018/_benefit_me.yaml | 72 ++++++++++++++----- .../family_scheme/family_tax_credit.py | 4 +- .../jobseeker_support/jobseeker_support.py | 1 + 3 files changed, 57 insertions(+), 20 deletions(-) diff --git a/openfisca_aotearoa/tests/social_security/accommodation_supplement/2018/_benefit_me.yaml b/openfisca_aotearoa/tests/social_security/accommodation_supplement/2018/_benefit_me.yaml index 80ee26f4..d1080458 100644 --- a/openfisca_aotearoa/tests/social_security/accommodation_supplement/2018/_benefit_me.yaml +++ b/openfisca_aotearoa/tests/social_security/accommodation_supplement/2018/_benefit_me.yaml @@ -1,6 +1,6 @@ - name: > BenefitMe - Peta's Story + Peta's Story (without family tax credit) period: 2022-12-05 relative_error_margin: 0.001 input: @@ -8,29 +8,63 @@ Peta: age: day:2022-01-01:365: 32 + social_security__residential_requirement: + 2022-W49: true social_security__in_a_relationship: - week:2022-W01:52: false + 2022-W49: false + social_security__dependent_children: + 2022-W49: 1 + jobseeker_support__minimum_income: + 2022-W49: true + family_tax_credit__eligible: + 2022: true accommodation_costs: - week:2022-W01:52: 350 + 2022-W49: 350 accommodation_type: - week:2022-W01:52: rent + 2022-W49: rent accommodation_supplement__area_of_residence: - week:2022-W01:52: area_2 + 2022-W49: area_2 + output: + jobseeker_support__benefit: + 2022-W49: 440.96 + accommodation_supplement: + 2022-W49: 155.00 + family_tax_credit: + 2022: 0 + + +- name: > + BenefitMe + Peta's Story (with family tax credit) + period: 2022-12-05 + relative_error_margin: 0.001 + input: + persons: + Peta: + age: + day:2022-01-01:365: 32 + social_security__residential_requirement: + 2022-W49: true + social_security__in_a_relationship: + 2022-W49: false + social_security__dependent_children: + 2022-W49: 1 + jobseeker_support__minimum_income: + 2022-W49: true family_tax_credit__eligible: 2022: true - jobseeker_support__entitled: - week:2022-W01:52: true + accommodation_costs: + 2022-W49: 350 + accommodation_type: + 2022-W49: rent + accommodation_supplement__area_of_residence: + 2022-W49: area_2 Anahera: - age: - day:2022-01-01:365: 5 - social_security__dependent_child: - week:2022-W01:52: true family_tax_credit__dependent_child: - 2022: true - family: - principal: Peta - children: [Anahera] + 2022: .5 output: + jobseeker_support__benefit: + 2022-W49: [440.96, 0] accommodation_supplement: 2022-W49: [145.54, 0] family_tax_credit: @@ -55,8 +89,10 @@ week:2022-W01:52: area_2 accommodation_supplement__cash_assets: 2022-W49: 800 - jobseeker_support__entitled: - week:2022-W01:52: true output: + jobseeker_support__benefit: + 2022-W49: 0 accommodation_supplement: - 2022-W49: 105.00 + 2022-W49: 105 + family_tax_credit: + 2022: 0 diff --git a/openfisca_aotearoa/variables/acts/income_tax/family_scheme/family_tax_credit.py b/openfisca_aotearoa/variables/acts/income_tax/family_scheme/family_tax_credit.py index 88cffa41..40e97dc9 100644 --- a/openfisca_aotearoa/variables/acts/income_tax/family_scheme/family_tax_credit.py +++ b/openfisca_aotearoa/variables/acts/income_tax/family_scheme/family_tax_credit.py @@ -62,7 +62,7 @@ def formula_2007_11_01(people, period, params): under_16y = age < 16 principal = people.has_role(Family.PRINCIPAL) caregived = people("family_tax_credit__dependent_child", period.this_year) - dependent = caregived >= 1 / 3 - .5 # last value is the error margin + dependent = caregived >= 1 / 3 - .005 # last value is the error margin eldest_child = sum(under_16y * dependent) - 1 >= 0 prescribed_amount = ( @@ -96,7 +96,7 @@ def formula_2007_11_01(people, period, params): under_16y = age < 16 principal = people.has_role(Family.PRINCIPAL) caregived = people("family_tax_credit__dependent_child", period.this_year) - dependent = caregived >= 1 / 3 - .5 # last value is the error margin + dependent = caregived >= 1 / 3 - .005 # last value is the error margin other_than_the_eldest_child = max([0, sum(under_16y * dependent) - 1]) prescribed_amount = ( diff --git a/openfisca_aotearoa/variables/acts/social_security/jobseeker_support/jobseeker_support.py b/openfisca_aotearoa/variables/acts/social_security/jobseeker_support/jobseeker_support.py index 75bcdef5..df2a11ac 100644 --- a/openfisca_aotearoa/variables/acts/social_security/jobseeker_support/jobseeker_support.py +++ b/openfisca_aotearoa/variables/acts/social_security/jobseeker_support/jobseeker_support.py @@ -157,6 +157,7 @@ class jobseeker_support__receiving(variables.Variable): label = "is receiving jobseeker support at the rate in clause 1(c), (e), or (f) of Part 1 of Schedule 4, SSA2018 21 3(a)" definition_period = periods.WEEK reference = "https://www.legislation.govt.nz/act/public/2018/0032/latest/whole.html#DLM6783146" + set_input = holders.set_input_dispatch_by_period class jobseeker_support__granted(variables.Variable): From 7811e38fbff901a2145967bf1968b4ffb75d2253 Mon Sep 17 00:00:00 2001 From: Mauko Quiroga Date: Tue, 26 Sep 2023 02:21:59 +0200 Subject: [PATCH 4/4] Bump version --- CHANGELOG.md | 11 +++++++---- pyproject.toml | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fe432ee6..7c313af8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,14 @@ # Changelog +### 20.1.1 - [48](https://github.com/digitalaotearoa/openfisca-aotearoa/pull/48) + +* Test case. +* Details: + - Add Peta & Kai's stories. + ## 20.1.0 - [57](https://github.com/digitalaotearoa/openfisca-aotearoa/pull/57) -* Technical improvement -* Impacted periods: all -* Impacted areas: all +* Technical improvement. * Details: - Catch up from mainstream, both dependencies and code evolution (bumped Numpy to ~1.24 and Python to 39-311) - These upgrades are critical as the aforesaid versions are EOL and do not easily compile in modern workstations (specially ARM64). @@ -32,7 +36,6 @@ * Details: - Add Peta's story - Add Kai's story ->>>>>>> 6f04876 (Bump version) # 20.0.0 - [43](https://github.com/govzeroaotearoa/openfisca-aotearoa/pull/43) diff --git a/pyproject.toml b/pyproject.toml index 5c0f4e08..22b05544 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "OpenFisca-Aotearoa" -version = "20.1.0" +version = "20.1.1" description = "OpenFisca rules-as-code system for Aotearoa." license = "AGPL-3.0-only" authors = [