From db62b68f37fcf0c2bb78c7af8cf912ac7394c295 Mon Sep 17 00:00:00 2001 From: admin Date: Sat, 19 May 2018 18:04:32 +1200 Subject: [PATCH 01/16] add citizenship variable --- openfisca_aotearoa/variables/general.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 openfisca_aotearoa/variables/general.py diff --git a/openfisca_aotearoa/variables/general.py b/openfisca_aotearoa/variables/general.py new file mode 100644 index 00000000..c84845e9 --- /dev/null +++ b/openfisca_aotearoa/variables/general.py @@ -0,0 +1,13 @@ +# Import from openfisca-core the common python objects used to code the legislation in OpenFisca +from openfisca_core.model_api import * +# Import the entities specifically defined for this tax and benefit system +from openfisca_aotearoa.entities import Person + + +class citizen(Variable): + value_type = bool + entity = Person + definition_period = ETERNITY + label = u"Number of Persons classified as dependant for the purposes of rates rebates" + reference = "http://www.legislation.govt.nz/act/public/1977/0061/latest/whole.html" + \ No newline at end of file From d0dd21e738ec4726e14572a467bbb1ec566456e6 Mon Sep 17 00:00:00 2001 From: JudyPuff Date: Sat, 19 May 2018 22:12:06 +1200 Subject: [PATCH 02/16] added kiwisaver.py and 3 variables --- openfisca_aotearoa/variables/kiwisaver.py | 31 +++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 openfisca_aotearoa/variables/kiwisaver.py diff --git a/openfisca_aotearoa/variables/kiwisaver.py b/openfisca_aotearoa/variables/kiwisaver.py new file mode 100644 index 00000000..b4fb1506 --- /dev/null +++ b/openfisca_aotearoa/variables/kiwisaver.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- + +# Import from openfisca-core the common python objects used to code the legislation in OpenFisca +from openfisca_core.model_api import * +# Import the entities specifically defined for this tax and benefit system +from openfisca_aotearoa.entities import Person + +#All variables are according to the reference link http://www.legislation.govt.nz/act/public/2006/0040/latest/DLM379487.html#DLM379487 + +class owned_home_before(Variable): + value_type = bool + entity = Person + definition_period = YEAR + label = u"Whether the prospective home buyer owned a home before" + +class has_ks(Variable): + value_type = bool + entity = Person + label = u"Whether the prospective home buyer has a kiwisaver account" + +class ks_duration(Variable): + value_type = int + entity = Person + definition_period = YEAR + label = u"Years the prospective home buyer has been a member of a kiwisaver account" + +class ks_contrib_duration: + value_type = int + entity = Person + definition_period = YEAR + label = u"Years the prospective home buyer has been contributing continuously to their kiwisaver account" From 3ec3a4bac0c0ccccbe3358e8613f25ffad85ce72 Mon Sep 17 00:00:00 2001 From: JudyPuff Date: Sat, 19 May 2018 23:24:50 +1200 Subject: [PATCH 03/16] added 2 yaml files under parameters --- .../parameters/kiwisaver/homestart/income_threshold.yaml | 7 +++++++ .../parameters/kiwisaver/homestart/ks_duration.yaml | 6 ++++++ 2 files changed, 13 insertions(+) create mode 100644 openfisca_aotearoa/parameters/kiwisaver/homestart/income_threshold.yaml create mode 100644 openfisca_aotearoa/parameters/kiwisaver/homestart/ks_duration.yaml diff --git a/openfisca_aotearoa/parameters/kiwisaver/homestart/income_threshold.yaml b/openfisca_aotearoa/parameters/kiwisaver/homestart/income_threshold.yaml new file mode 100644 index 00000000..5c095a30 --- /dev/null +++ b/openfisca_aotearoa/parameters/kiwisaver/homestart/income_threshold.yaml @@ -0,0 +1,7 @@ +description: Income threshold +reference: "https://www.hnzc.co.nz/ways-we-can-help-you-to-own-a-home/kiwisaver-homestart-grant-and-savings-withdrawal/kiwisaver-homestart-grant/homestart-grant-eligibility-checklist/" +values: +single_buyer: + value: 85000 +multiple_buyer: + value: 130000 \ No newline at end of file diff --git a/openfisca_aotearoa/parameters/kiwisaver/homestart/ks_duration.yaml b/openfisca_aotearoa/parameters/kiwisaver/homestart/ks_duration.yaml new file mode 100644 index 00000000..4d76a3e9 --- /dev/null +++ b/openfisca_aotearoa/parameters/kiwisaver/homestart/ks_duration.yaml @@ -0,0 +1,6 @@ +description: Length of kiwisaver membership +reference: "http://www.legislation.govt.nz/act/public/2006/0040/latest/DLM379487.html#DLM379487" +values: +years_membership: + value: 3 +#need to do more research under s8 Schedule 1 of the Kiwisaver Act \ No newline at end of file From f868d333118045c0b10cd0421a4b4b684e2bc705 Mon Sep 17 00:00:00 2001 From: JudyPuff Date: Sun, 20 May 2018 05:09:34 +1200 Subject: [PATCH 04/16] added prop_threshold yamls and more classes in kiwisaver variable --- .../homestart/akl_prop_threshold.yaml | 5 ++++ ...shold.yaml => indiv_income_threshold.yaml} | 6 ++--- .../homestart/mid_nz_prop_threshold.yaml | 5 ++++ .../homestart/rest_of_nz_prop_threshold.yaml | 5 ++++ openfisca_aotearoa/variables/kiwisaver.py | 25 +++++++++++++++++-- 5 files changed, 40 insertions(+), 6 deletions(-) create mode 100644 openfisca_aotearoa/parameters/kiwisaver/homestart/akl_prop_threshold.yaml rename openfisca_aotearoa/parameters/kiwisaver/homestart/{income_threshold.yaml => indiv_income_threshold.yaml} (78%) create mode 100644 openfisca_aotearoa/parameters/kiwisaver/homestart/mid_nz_prop_threshold.yaml create mode 100644 openfisca_aotearoa/parameters/kiwisaver/homestart/rest_of_nz_prop_threshold.yaml diff --git a/openfisca_aotearoa/parameters/kiwisaver/homestart/akl_prop_threshold.yaml b/openfisca_aotearoa/parameters/kiwisaver/homestart/akl_prop_threshold.yaml new file mode 100644 index 00000000..221509ff --- /dev/null +++ b/openfisca_aotearoa/parameters/kiwisaver/homestart/akl_prop_threshold.yaml @@ -0,0 +1,5 @@ +description: Property price threshold to be eligible for the Homestart grant for Auckland +reference: +values: + Auckland: # find date this was set + value: 600000 diff --git a/openfisca_aotearoa/parameters/kiwisaver/homestart/income_threshold.yaml b/openfisca_aotearoa/parameters/kiwisaver/homestart/indiv_income_threshold.yaml similarity index 78% rename from openfisca_aotearoa/parameters/kiwisaver/homestart/income_threshold.yaml rename to openfisca_aotearoa/parameters/kiwisaver/homestart/indiv_income_threshold.yaml index 5c095a30..21ee503d 100644 --- a/openfisca_aotearoa/parameters/kiwisaver/homestart/income_threshold.yaml +++ b/openfisca_aotearoa/parameters/kiwisaver/homestart/indiv_income_threshold.yaml @@ -1,7 +1,5 @@ description: Income threshold reference: "https://www.hnzc.co.nz/ways-we-can-help-you-to-own-a-home/kiwisaver-homestart-grant-and-savings-withdrawal/kiwisaver-homestart-grant/homestart-grant-eligibility-checklist/" values: -single_buyer: - value: 85000 -multiple_buyer: - value: 130000 \ No newline at end of file +indiv_buyer: #find the date this was set + value: 85000 \ No newline at end of file diff --git a/openfisca_aotearoa/parameters/kiwisaver/homestart/mid_nz_prop_threshold.yaml b/openfisca_aotearoa/parameters/kiwisaver/homestart/mid_nz_prop_threshold.yaml new file mode 100644 index 00000000..2a471fd7 --- /dev/null +++ b/openfisca_aotearoa/parameters/kiwisaver/homestart/mid_nz_prop_threshold.yaml @@ -0,0 +1,5 @@ +description: Highest price of property in the areas of Hamilton, Tauranga, Western Bay of Plenty, Kapiti Coast, Porirua, Upper Hutt, Hutt City, Wellington, Tasman, Nelson, Waimakariri, Christchurch, Selwyn, Queenstown Lakes Disctrict +reference: +values: + Hamilton || Tauranga || Western Bay of Plenty || Kapiti Coast || Porirua || Upper Hutt || Hutt City || Wellington || Tasman || Nelson || Waimakariri || Christchurch || Selwyn || Queenstown Lakes Disctrict: # find date this was set + value: 500000 diff --git a/openfisca_aotearoa/parameters/kiwisaver/homestart/rest_of_nz_prop_threshold.yaml b/openfisca_aotearoa/parameters/kiwisaver/homestart/rest_of_nz_prop_threshold.yaml new file mode 100644 index 00000000..13d54f1a --- /dev/null +++ b/openfisca_aotearoa/parameters/kiwisaver/homestart/rest_of_nz_prop_threshold.yaml @@ -0,0 +1,5 @@ +description: Property price threshold to be eligible for the Homestart grant for the rest of NZ +reference: +values: + Rest of NZ: # find date this was set + value: 400000 diff --git a/openfisca_aotearoa/variables/kiwisaver.py b/openfisca_aotearoa/variables/kiwisaver.py index b4fb1506..a7fd33af 100644 --- a/openfisca_aotearoa/variables/kiwisaver.py +++ b/openfisca_aotearoa/variables/kiwisaver.py @@ -3,7 +3,7 @@ # Import from openfisca-core the common python objects used to code the legislation in OpenFisca from openfisca_core.model_api import * # Import the entities specifically defined for this tax and benefit system -from openfisca_aotearoa.entities import Person +from openfisca_aotearoa.entities import Titled_Property, Person #All variables are according to the reference link http://www.legislation.govt.nz/act/public/2006/0040/latest/DLM379487.html#DLM379487 @@ -24,8 +24,29 @@ class ks_duration(Variable): definition_period = YEAR label = u"Years the prospective home buyer has been a member of a kiwisaver account" -class ks_contrib_duration: +class ks_contrib_duration(Variable): value_type = int entity = Person definition_period = YEAR label = u"Years the prospective home buyer has been contributing continuously to their kiwisaver account" + +class purc_price(Variable): + value_type = int + entity = Titled_Property + definition_period = YEAR + label = u"Purchase price of the proposed home" + +class indv_income_per_hs_grant(Variable): + value_type = int + entity = Person + definition_period = YEAR + set_input = set_input_divide_by_period + # Check how to set input by user and check against the threshold + +class combined_income_per_hs_grant(Variable): + value_type = int + entity = Person + definition_period = YEAR + set_input = set_input_divide_by_period # Allows user to declare a salary for a year. + # Check how to set input by user and check against the threshold + label = "Combined income" From 0841171acdc5fbfe7e0054d78a98783a3c7846ce Mon Sep 17 00:00:00 2001 From: JudyPuff Date: Sun, 20 May 2018 12:28:18 +1200 Subject: [PATCH 05/16] added formula for hs_grant calculation based on years of contribution --- .../homestart/akl_prop_threshold.yaml | 2 +- .../homestart/indiv_income_threshold.yaml | 4 +-- .../kiwisaver/homestart/ks_duration.yaml | 4 +-- .../homestart/mid_nz_prop_threshold.yaml | 4 +-- .../homestart/rest_of_nz_prop_threshold.yaml | 2 +- openfisca_aotearoa/tests/kiwisaver.yaml | 31 ++++++++++++++++ openfisca_aotearoa/variables/kiwisaver.py | 36 ++++++++++++------- 7 files changed, 62 insertions(+), 21 deletions(-) create mode 100644 openfisca_aotearoa/tests/kiwisaver.yaml diff --git a/openfisca_aotearoa/parameters/kiwisaver/homestart/akl_prop_threshold.yaml b/openfisca_aotearoa/parameters/kiwisaver/homestart/akl_prop_threshold.yaml index 221509ff..9d1a7c4a 100644 --- a/openfisca_aotearoa/parameters/kiwisaver/homestart/akl_prop_threshold.yaml +++ b/openfisca_aotearoa/parameters/kiwisaver/homestart/akl_prop_threshold.yaml @@ -1,5 +1,5 @@ description: Property price threshold to be eligible for the Homestart grant for Auckland reference: values: - Auckland: # find date this was set + 2006-01: # find date this was set value: 600000 diff --git a/openfisca_aotearoa/parameters/kiwisaver/homestart/indiv_income_threshold.yaml b/openfisca_aotearoa/parameters/kiwisaver/homestart/indiv_income_threshold.yaml index 21ee503d..2d624d42 100644 --- a/openfisca_aotearoa/parameters/kiwisaver/homestart/indiv_income_threshold.yaml +++ b/openfisca_aotearoa/parameters/kiwisaver/homestart/indiv_income_threshold.yaml @@ -1,5 +1,5 @@ description: Income threshold reference: "https://www.hnzc.co.nz/ways-we-can-help-you-to-own-a-home/kiwisaver-homestart-grant-and-savings-withdrawal/kiwisaver-homestart-grant/homestart-grant-eligibility-checklist/" values: -indiv_buyer: #find the date this was set - value: 85000 \ No newline at end of file + 2006-01: #find the date this was set + value: 85000 \ No newline at end of file diff --git a/openfisca_aotearoa/parameters/kiwisaver/homestart/ks_duration.yaml b/openfisca_aotearoa/parameters/kiwisaver/homestart/ks_duration.yaml index 4d76a3e9..f34c840f 100644 --- a/openfisca_aotearoa/parameters/kiwisaver/homestart/ks_duration.yaml +++ b/openfisca_aotearoa/parameters/kiwisaver/homestart/ks_duration.yaml @@ -1,6 +1,6 @@ description: Length of kiwisaver membership reference: "http://www.legislation.govt.nz/act/public/2006/0040/latest/DLM379487.html#DLM379487" values: -years_membership: - value: 3 + 2006-01: + value: 3 #need to do more research under s8 Schedule 1 of the Kiwisaver Act \ No newline at end of file diff --git a/openfisca_aotearoa/parameters/kiwisaver/homestart/mid_nz_prop_threshold.yaml b/openfisca_aotearoa/parameters/kiwisaver/homestart/mid_nz_prop_threshold.yaml index 2a471fd7..f45dc06c 100644 --- a/openfisca_aotearoa/parameters/kiwisaver/homestart/mid_nz_prop_threshold.yaml +++ b/openfisca_aotearoa/parameters/kiwisaver/homestart/mid_nz_prop_threshold.yaml @@ -1,5 +1,5 @@ -description: Highest price of property in the areas of Hamilton, Tauranga, Western Bay of Plenty, Kapiti Coast, Porirua, Upper Hutt, Hutt City, Wellington, Tasman, Nelson, Waimakariri, Christchurch, Selwyn, Queenstown Lakes Disctrict +description: Property price threshold to be eligible for the Homestart grant in the areas of Hamilton, Tauranga, Western Bay of Plenty, Kapiti Coast, Porirua, Upper Hutt, Hutt City, Wellington, Tasman, Nelson, Waimakariri, Christchurch, Selwyn, Queenstown Lakes Disctrict reference: values: - Hamilton || Tauranga || Western Bay of Plenty || Kapiti Coast || Porirua || Upper Hutt || Hutt City || Wellington || Tasman || Nelson || Waimakariri || Christchurch || Selwyn || Queenstown Lakes Disctrict: # find date this was set + 2006-01: # find date this was set value: 500000 diff --git a/openfisca_aotearoa/parameters/kiwisaver/homestart/rest_of_nz_prop_threshold.yaml b/openfisca_aotearoa/parameters/kiwisaver/homestart/rest_of_nz_prop_threshold.yaml index 13d54f1a..2b3efc06 100644 --- a/openfisca_aotearoa/parameters/kiwisaver/homestart/rest_of_nz_prop_threshold.yaml +++ b/openfisca_aotearoa/parameters/kiwisaver/homestart/rest_of_nz_prop_threshold.yaml @@ -1,5 +1,5 @@ description: Property price threshold to be eligible for the Homestart grant for the rest of NZ reference: values: - Rest of NZ: # find date this was set + 2006-01: # find date this was set value: 400000 diff --git a/openfisca_aotearoa/tests/kiwisaver.yaml b/openfisca_aotearoa/tests/kiwisaver.yaml new file mode 100644 index 00000000..6c007b99 --- /dev/null +++ b/openfisca_aotearoa/tests/kiwisaver.yaml @@ -0,0 +1,31 @@ +- name: If contributed for less than 3 years, not entitled to grant + period: 2018-01 + absolute_error_margin: 0 + input_variables: + ks_contrib_duration: 2 + output_variables: + homestart_grant: 0 + +- name: If contributed for 3 years, entitled to $3000 + period: 2018-01 + absolute_error_margin: 0 + input_variables: + ks_contrib_duration: 3 + output_variables: + homestart_grant: 3000 + +- name: If contributed for 4 years, entitled to $4000 + period: 2018-01 + absolute_error_margin: 0 + input_variables: + ks_contrib_duration: 4 + output_variables: + homestart_grant: 4000 + +- name: If contributed for over 5 years, entitled to $5000 + period: 2018-01 + absolute_error_margin: 0 + input_variables: + ks_contrib_duration: 7 + output_variables: + homestart_grant: 5000 \ No newline at end of file diff --git a/openfisca_aotearoa/variables/kiwisaver.py b/openfisca_aotearoa/variables/kiwisaver.py index a7fd33af..baba3aa4 100644 --- a/openfisca_aotearoa/variables/kiwisaver.py +++ b/openfisca_aotearoa/variables/kiwisaver.py @@ -4,32 +4,42 @@ from openfisca_core.model_api import * # Import the entities specifically defined for this tax and benefit system from openfisca_aotearoa.entities import Titled_Property, Person +from numpy import clip #All variables are according to the reference link http://www.legislation.govt.nz/act/public/2006/0040/latest/DLM379487.html#DLM379487 -class owned_home_before(Variable): - value_type = bool - entity = Person - definition_period = YEAR - label = u"Whether the prospective home buyer owned a home before" - -class has_ks(Variable): - value_type = bool - entity = Person - label = u"Whether the prospective home buyer has a kiwisaver account" - class ks_duration(Variable): value_type = int entity = Person - definition_period = YEAR + definition_period = MONTH label = u"Years the prospective home buyer has been a member of a kiwisaver account" class ks_contrib_duration(Variable): value_type = int entity = Person - definition_period = YEAR + definition_period = MONTH label = u"Years the prospective home buyer has been contributing continuously to their kiwisaver account" +class ks_contrib_duration_satisfied(Variable): + value_type = bool + entity = Person + definition_period = MONTH + label = u"This flag returns true or false if the contribution period is valid" + + def formula(persons, period): + return persons('ks_contrib_duration', period) >= 3 + +class homestart_grant(Variable): + value_type = float + entity = Person + definition_period = MONTH + label = u"Amount available to you from the Homestart grant" + + def formula(persons, period): + duration = persons('ks_contrib_duration', period) + HS_grant = persons('ks_contrib_duration', period) * persons('ks_contrib_duration_satisfied', period) * 1000 + return clip(HS_grant,0,5000) + class purc_price(Variable): value_type = int entity = Titled_Property From 4b74409736096c54ee3a6a3172dddd05d182819e Mon Sep 17 00:00:00 2001 From: JudyPuff Date: Wed, 23 May 2018 19:21:06 +1200 Subject: [PATCH 06/16] added kiwisaver parameters and variables with Hamish --- .../kiwisaver/homestart/ks_duration.yaml | 2 +- openfisca_aotearoa/tests/kiwisaver.yaml | 8 +- openfisca_aotearoa/variables/kiwisaver.py | 86 +++++++++++++++++-- 3 files changed, 86 insertions(+), 10 deletions(-) diff --git a/openfisca_aotearoa/parameters/kiwisaver/homestart/ks_duration.yaml b/openfisca_aotearoa/parameters/kiwisaver/homestart/ks_duration.yaml index f34c840f..7f03eefb 100644 --- a/openfisca_aotearoa/parameters/kiwisaver/homestart/ks_duration.yaml +++ b/openfisca_aotearoa/parameters/kiwisaver/homestart/ks_duration.yaml @@ -1,4 +1,4 @@ -description: Length of kiwisaver membership +description: Length of contribution to kiwisaver account reference: "http://www.legislation.govt.nz/act/public/2006/0040/latest/DLM379487.html#DLM379487" values: 2006-01: diff --git a/openfisca_aotearoa/tests/kiwisaver.yaml b/openfisca_aotearoa/tests/kiwisaver.yaml index 6c007b99..4aa12e95 100644 --- a/openfisca_aotearoa/tests/kiwisaver.yaml +++ b/openfisca_aotearoa/tests/kiwisaver.yaml @@ -2,7 +2,7 @@ period: 2018-01 absolute_error_margin: 0 input_variables: - ks_contrib_duration: 2 + contrib_duration_as_per_kiwisaver: 2 output_variables: homestart_grant: 0 @@ -10,7 +10,7 @@ period: 2018-01 absolute_error_margin: 0 input_variables: - ks_contrib_duration: 3 + contrib_duration_as_per_kiwisaver: 3 output_variables: homestart_grant: 3000 @@ -18,7 +18,7 @@ period: 2018-01 absolute_error_margin: 0 input_variables: - ks_contrib_duration: 4 + contrib_duration_as_per_kiwisaver: 4 output_variables: homestart_grant: 4000 @@ -26,6 +26,6 @@ period: 2018-01 absolute_error_margin: 0 input_variables: - ks_contrib_duration: 7 + contrib_duration_as_per_kiwisaver: 7 output_variables: homestart_grant: 5000 \ No newline at end of file diff --git a/openfisca_aotearoa/variables/kiwisaver.py b/openfisca_aotearoa/variables/kiwisaver.py index baba3aa4..32ff232d 100644 --- a/openfisca_aotearoa/variables/kiwisaver.py +++ b/openfisca_aotearoa/variables/kiwisaver.py @@ -14,13 +14,13 @@ class ks_duration(Variable): definition_period = MONTH label = u"Years the prospective home buyer has been a member of a kiwisaver account" -class ks_contrib_duration(Variable): +class contrib_duration__kiwisaver(Variable): value_type = int entity = Person definition_period = MONTH label = u"Years the prospective home buyer has been contributing continuously to their kiwisaver account" -class ks_contrib_duration_satisfied(Variable): +class contrib_duration__kiwisaver(Variable): value_type = bool entity = Person definition_period = MONTH @@ -29,23 +29,99 @@ class ks_contrib_duration_satisfied(Variable): def formula(persons, period): return persons('ks_contrib_duration', period) >= 3 -class homestart_grant(Variable): +class homestart_grant__kiwisaver(Variable): value_type = float entity = Person definition_period = MONTH label = u"Amount available to you from the Homestart grant" def formula(persons, period): - duration = persons('ks_contrib_duration', period) HS_grant = persons('ks_contrib_duration', period) * persons('ks_contrib_duration_satisfied', period) * 1000 return clip(HS_grant,0,5000) + class purc_price(Variable): value_type = int - entity = Titled_Property + entity = Person definition_period = YEAR label = u"Purchase price of the proposed home" + +class lvr_deposit_req__kiwisaver(Variable): + value_type = float + entity = Person + definition_period = MONTH + label = u"Loan to value ratio deposit requirement" + + def formula(persons, period): + return persons('purc_price', period) * 0.2 + + +class homestart_deposit_req__kiwisaver(Variable): + value_type = float + entity = Person + definition_period = MONTH + label = u"Homestart grant deposit requirement" + + def formula(persons, period): + return persons('purc_price', period) * 0.1 + + +class total_savings__kiwisaver(Variable): + value_type = float + entity = Person + definition_period = MONTH + label = u"Homestart grant deposit requirement" + + def formula(persons, period): + return persons('savings__kiwisaver', period) + persons('homestart_grant__kiwisaver', period) + persons('net__kiwisaver', period) + + +class gross__kiwisaver(Variable): + value_type = float + entity = Person + definition_period = MONTH + label = u"Gross kiwi saver balance" + + +class net__kiwisaver(Variable): + value_type = float + entity = Person + definition_period = MONTH + label = u"Gross kiwi saver balance" + + def formula(persons, period): + return persons('gross__kiwisaver', period) - 1000 + + +# The savings variable is for the purposes of calculating how much deposit, it's not part of the kiwisaver legislation +class savings__kiwisaver(Variable): + value_type = float + entity = Person + definition_period = MONTH + label = u"Personal cash savings in bank" + + +class homestart_deposit_eligible(Variable): + value_type = float + entity = Person + definition_period = MONTH + label = u"Deposit amount needed to be eligble for homestart grant" + + def formula(persons, period): + return persons('total_savings__kiwisaver', period) >= persons('homestart_deposit_req__kiwisaver', period) + + +class lvr_deposit_eligible(Variable): + value_type = float + entity = Person + definition_period = MONTH + label = u"Deposit amount needed to be eligble for homestart grant" + + def formula(persons, period): + return persons('total_savings__kiwisaver', period) >= persons('lvr_deposit_req__kiwisaver', period) + + class indv_income_per_hs_grant(Variable): value_type = int entity = Person From 596b574b83c0dadd91b0018e8c84ab3338fb575e Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 29 May 2018 13:37:45 +1200 Subject: [PATCH 07/16] Pep8 fixes --- openfisca_aotearoa/variables/general.py | 1 - openfisca_aotearoa/variables/kiwisaver.py | 17 ++++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/openfisca_aotearoa/variables/general.py b/openfisca_aotearoa/variables/general.py index c84845e9..cc00f36e 100644 --- a/openfisca_aotearoa/variables/general.py +++ b/openfisca_aotearoa/variables/general.py @@ -10,4 +10,3 @@ class citizen(Variable): definition_period = ETERNITY label = u"Number of Persons classified as dependant for the purposes of rates rebates" reference = "http://www.legislation.govt.nz/act/public/1977/0061/latest/whole.html" - \ No newline at end of file diff --git a/openfisca_aotearoa/variables/kiwisaver.py b/openfisca_aotearoa/variables/kiwisaver.py index 32ff232d..1fb5223b 100644 --- a/openfisca_aotearoa/variables/kiwisaver.py +++ b/openfisca_aotearoa/variables/kiwisaver.py @@ -6,7 +6,8 @@ from openfisca_aotearoa.entities import Titled_Property, Person from numpy import clip -#All variables are according to the reference link http://www.legislation.govt.nz/act/public/2006/0040/latest/DLM379487.html#DLM379487 +# All variables are according to the reference link http://www.legislation.govt.nz/act/public/2006/0040/latest/DLM379487.html#DLM379487 + class ks_duration(Variable): value_type = int @@ -14,12 +15,14 @@ class ks_duration(Variable): definition_period = MONTH label = u"Years the prospective home buyer has been a member of a kiwisaver account" + class contrib_duration__kiwisaver(Variable): value_type = int entity = Person definition_period = MONTH label = u"Years the prospective home buyer has been contributing continuously to their kiwisaver account" + class contrib_duration__kiwisaver(Variable): value_type = bool entity = Person @@ -29,6 +32,7 @@ class contrib_duration__kiwisaver(Variable): def formula(persons, period): return persons('ks_contrib_duration', period) >= 3 + class homestart_grant__kiwisaver(Variable): value_type = float entity = Person @@ -36,8 +40,9 @@ class homestart_grant__kiwisaver(Variable): label = u"Amount available to you from the Homestart grant" def formula(persons, period): - HS_grant = persons('ks_contrib_duration', period) * persons('ks_contrib_duration_satisfied', period) * 1000 - return clip(HS_grant,0,5000) + HS_grant = persons('ks_contrib_duration', period) * \ + persons('ks_contrib_duration_satisfied', period) * 1000 + return clip(HS_grant, 0, 5000) class purc_price(Variable): @@ -110,7 +115,7 @@ class homestart_deposit_eligible(Variable): def formula(persons, period): return persons('total_savings__kiwisaver', period) >= persons('homestart_deposit_req__kiwisaver', period) - + class lvr_deposit_eligible(Variable): value_type = float @@ -129,10 +134,12 @@ class indv_income_per_hs_grant(Variable): set_input = set_input_divide_by_period # Check how to set input by user and check against the threshold + class combined_income_per_hs_grant(Variable): value_type = int entity = Person definition_period = YEAR - set_input = set_input_divide_by_period # Allows user to declare a salary for a year. + # Allows user to declare a salary for a year. + set_input = set_input_divide_by_period # Check how to set input by user and check against the threshold label = "Combined income" From adedacf586f20e3ebe5f9d914ac2129e158bd1fa Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 29 May 2018 13:39:55 +1200 Subject: [PATCH 08/16] Removed unused import --- openfisca_aotearoa/variables/kiwisaver.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openfisca_aotearoa/variables/kiwisaver.py b/openfisca_aotearoa/variables/kiwisaver.py index 1fb5223b..47bdb38b 100644 --- a/openfisca_aotearoa/variables/kiwisaver.py +++ b/openfisca_aotearoa/variables/kiwisaver.py @@ -3,7 +3,7 @@ # Import from openfisca-core the common python objects used to code the legislation in OpenFisca from openfisca_core.model_api import * # Import the entities specifically defined for this tax and benefit system -from openfisca_aotearoa.entities import Titled_Property, Person +from openfisca_aotearoa.entities import Person from numpy import clip # All variables are according to the reference link http://www.legislation.govt.nz/act/public/2006/0040/latest/DLM379487.html#DLM379487 From 9d07eaca917b26d5ae0125142f7152d2507b437d Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 29 May 2018 13:45:28 +1200 Subject: [PATCH 09/16] Renamed class - meets contrib duration requirement --- openfisca_aotearoa/variables/kiwisaver.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openfisca_aotearoa/variables/kiwisaver.py b/openfisca_aotearoa/variables/kiwisaver.py index 47bdb38b..8493d007 100644 --- a/openfisca_aotearoa/variables/kiwisaver.py +++ b/openfisca_aotearoa/variables/kiwisaver.py @@ -23,7 +23,7 @@ class contrib_duration__kiwisaver(Variable): label = u"Years the prospective home buyer has been contributing continuously to their kiwisaver account" -class contrib_duration__kiwisaver(Variable): +class meets_contrib_duration_requirement__kiwisaver(Variable): value_type = bool entity = Person definition_period = MONTH From 73e130a815c3d25b2e9fc58d479c705957479767 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 29 May 2018 13:58:18 +1200 Subject: [PATCH 10/16] Rename variales in test to have __kiwisaver --- openfisca_aotearoa/tests/kiwisaver.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/openfisca_aotearoa/tests/kiwisaver.yaml b/openfisca_aotearoa/tests/kiwisaver.yaml index 4aa12e95..e8d6246a 100644 --- a/openfisca_aotearoa/tests/kiwisaver.yaml +++ b/openfisca_aotearoa/tests/kiwisaver.yaml @@ -4,7 +4,7 @@ input_variables: contrib_duration_as_per_kiwisaver: 2 output_variables: - homestart_grant: 0 + homestart_grant__kiwisaver: 0 - name: If contributed for 3 years, entitled to $3000 period: 2018-01 @@ -12,7 +12,7 @@ input_variables: contrib_duration_as_per_kiwisaver: 3 output_variables: - homestart_grant: 3000 + homestart_grant__kiwisaver: 3000 - name: If contributed for 4 years, entitled to $4000 period: 2018-01 @@ -20,7 +20,7 @@ input_variables: contrib_duration_as_per_kiwisaver: 4 output_variables: - homestart_grant: 4000 + homestart_grant__kiwisaver: 4000 - name: If contributed for over 5 years, entitled to $5000 period: 2018-01 @@ -28,4 +28,4 @@ input_variables: contrib_duration_as_per_kiwisaver: 7 output_variables: - homestart_grant: 5000 \ No newline at end of file + homestart_grant__kiwisaver: 5000 \ No newline at end of file From 740b95433e56f7c935585e62b9c74709f4d7c1f8 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 29 May 2018 14:00:41 +1200 Subject: [PATCH 11/16] Matching test variables to the python --- openfisca_aotearoa/tests/kiwisaver.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/openfisca_aotearoa/tests/kiwisaver.yaml b/openfisca_aotearoa/tests/kiwisaver.yaml index e8d6246a..3df1e0e1 100644 --- a/openfisca_aotearoa/tests/kiwisaver.yaml +++ b/openfisca_aotearoa/tests/kiwisaver.yaml @@ -2,7 +2,7 @@ period: 2018-01 absolute_error_margin: 0 input_variables: - contrib_duration_as_per_kiwisaver: 2 + contrib_duration__kiwisaver: 2 output_variables: homestart_grant__kiwisaver: 0 @@ -10,7 +10,7 @@ period: 2018-01 absolute_error_margin: 0 input_variables: - contrib_duration_as_per_kiwisaver: 3 + contrib_duration__kiwisaver: 3 output_variables: homestart_grant__kiwisaver: 3000 @@ -18,7 +18,7 @@ period: 2018-01 absolute_error_margin: 0 input_variables: - contrib_duration_as_per_kiwisaver: 4 + contrib_duration__kiwisaver: 4 output_variables: homestart_grant__kiwisaver: 4000 @@ -26,6 +26,6 @@ period: 2018-01 absolute_error_margin: 0 input_variables: - contrib_duration_as_per_kiwisaver: 7 + contrib_duration__kiwisaver: 7 output_variables: homestart_grant__kiwisaver: 5000 \ No newline at end of file From cb8c06fb0fefbd4e23ad0181dcd1d8856cacc1db Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 29 May 2018 14:04:52 +1200 Subject: [PATCH 12/16] Fixing more variable names --- openfisca_aotearoa/variables/kiwisaver.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openfisca_aotearoa/variables/kiwisaver.py b/openfisca_aotearoa/variables/kiwisaver.py index 8493d007..a428ad0a 100644 --- a/openfisca_aotearoa/variables/kiwisaver.py +++ b/openfisca_aotearoa/variables/kiwisaver.py @@ -30,7 +30,7 @@ class meets_contrib_duration_requirement__kiwisaver(Variable): label = u"This flag returns true or false if the contribution period is valid" def formula(persons, period): - return persons('ks_contrib_duration', period) >= 3 + return persons('contrib_duration__kiwisaver', period) >= 3 class homestart_grant__kiwisaver(Variable): From f918a83fbb8210b88e1e5f7012b6fb4706e8cd76 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 29 May 2018 14:10:50 +1200 Subject: [PATCH 13/16] Rename purc_price to purchase_price --- openfisca_aotearoa/variables/kiwisaver.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openfisca_aotearoa/variables/kiwisaver.py b/openfisca_aotearoa/variables/kiwisaver.py index 8493d007..bad95c75 100644 --- a/openfisca_aotearoa/variables/kiwisaver.py +++ b/openfisca_aotearoa/variables/kiwisaver.py @@ -45,7 +45,7 @@ def formula(persons, period): return clip(HS_grant, 0, 5000) -class purc_price(Variable): +class purchase_price(Variable): value_type = int entity = Person definition_period = YEAR @@ -59,7 +59,7 @@ class lvr_deposit_req__kiwisaver(Variable): label = u"Loan to value ratio deposit requirement" def formula(persons, period): - return persons('purc_price', period) * 0.2 + return persons('purchase_price', period) * 0.2 class homestart_deposit_req__kiwisaver(Variable): @@ -69,7 +69,7 @@ class homestart_deposit_req__kiwisaver(Variable): label = u"Homestart grant deposit requirement" def formula(persons, period): - return persons('purc_price', period) * 0.1 + return persons('purchase_price', period) * 0.1 class total_savings__kiwisaver(Variable): From cf586c0b3b4d1d435ba26da5dd823482bf3ba08d Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 1 Jun 2018 14:58:49 +1200 Subject: [PATCH 14/16] Clearer variable name --- openfisca_aotearoa/variables/kiwisaver.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openfisca_aotearoa/variables/kiwisaver.py b/openfisca_aotearoa/variables/kiwisaver.py index bad95c75..1e633b8e 100644 --- a/openfisca_aotearoa/variables/kiwisaver.py +++ b/openfisca_aotearoa/variables/kiwisaver.py @@ -9,7 +9,7 @@ # All variables are according to the reference link http://www.legislation.govt.nz/act/public/2006/0040/latest/DLM379487.html#DLM379487 -class ks_duration(Variable): +class duration__kiwisaver(Variable): value_type = int entity = Person definition_period = MONTH @@ -40,8 +40,8 @@ class homestart_grant__kiwisaver(Variable): label = u"Amount available to you from the Homestart grant" def formula(persons, period): - HS_grant = persons('ks_contrib_duration', period) * \ - persons('ks_contrib_duration_satisfied', period) * 1000 + HS_grant = persons('duration__kiwisaver', period) * \ + persons('contrib_duration__kiwisaver', period) * 1000 return clip(HS_grant, 0, 5000) From 7ba867351577a958e7f0498b1cdeab2d5333c319 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 1 Jun 2018 15:32:45 +1200 Subject: [PATCH 15/16] refactor - rename variable to have kiwisaver at start --- openfisca_aotearoa/variables/kiwisaver.py | 44 +++++++++++------------ 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/openfisca_aotearoa/variables/kiwisaver.py b/openfisca_aotearoa/variables/kiwisaver.py index 19e3754e..b1d0f2b6 100644 --- a/openfisca_aotearoa/variables/kiwisaver.py +++ b/openfisca_aotearoa/variables/kiwisaver.py @@ -9,28 +9,28 @@ # All variables are according to the reference link http://www.legislation.govt.nz/act/public/2006/0040/latest/DLM379487.html#DLM379487 -class duration__kiwisaver(Variable): +class kiwisaver__duration(Variable): value_type = int entity = Person definition_period = MONTH label = u"Years the prospective home buyer has been a member of a kiwisaver account" -class contrib_duration__kiwisaver(Variable): +class kiwisaver__contrib_duration(Variable): value_type = int entity = Person definition_period = MONTH label = u"Years the prospective home buyer has been contributing continuously to their kiwisaver account" -class meets_contrib_duration_requirement__kiwisaver(Variable): +class kiwiserver__meets_contrib_duration_requirement(Variable): value_type = bool entity = Person definition_period = MONTH label = u"This flag returns true or false if the contribution period is valid" def formula(persons, period): - return persons('contrib_duration__kiwisaver', period) >= 3 + return persons('kiwisaver__contrib_duration', period) >= 3 class homestart_grant__kiwisaver(Variable): @@ -40,26 +40,26 @@ class homestart_grant__kiwisaver(Variable): label = u"Amount available to you from the Homestart grant" def formula(persons, period): - HS_grant = persons('duration__kiwisaver', period) * \ - persons('contrib_duration__kiwisaver', period) * 1000 + HS_grant = persons('kiwisaver__duration', period) * \ + persons('kiwisaver__contrib_duration', period) * 1000 return clip(HS_grant, 0, 5000) -class purchase_price(Variable): +class kiwisaver__purchase_price(Variable): value_type = int entity = Person definition_period = YEAR label = u"Purchase price of the proposed home" -class lvr_deposit_req__kiwisaver(Variable): +class kiwisaver__lvr_deposit_req(Variable): value_type = float entity = Person definition_period = MONTH label = u"Loan to value ratio deposit requirement" def formula(persons, period): - return persons('purchase_price', period) * 0.2 + return persons('kiwisaver__purchase_price', period) * 0.2 class homestart_deposit_req__kiwisaver(Variable): @@ -69,65 +69,65 @@ class homestart_deposit_req__kiwisaver(Variable): label = u"Homestart grant deposit requirement" def formula(persons, period): - return persons('purchase_price', period) * 0.1 + return persons('kiwisaver__purchase_price', period) * 0.1 -class total_savings__kiwisaver(Variable): +class kiwisaver__total_savings(Variable): value_type = float entity = Person definition_period = MONTH label = u"Homestart grant deposit requirement" def formula(persons, period): - return persons('savings__kiwisaver', period) + persons('homestart_grant__kiwisaver', period) + persons('net__kiwisaver', period) + return persons('kiwisaver__savings', period) + persons('homestart_grant__kiwisaver', period) + persons('kiwisaver__net', period) -class gross__kiwisaver(Variable): +class kiwisaver__gross(Variable): value_type = float entity = Person definition_period = MONTH label = u"Gross kiwi saver balance" -class net__kiwisaver(Variable): +class kiwisaver__net(Variable): value_type = float entity = Person definition_period = MONTH label = u"Gross kiwi saver balance" def formula(persons, period): - return persons('gross__kiwisaver', period) - 1000 + return persons('kiwisaver__gross', period) - 1000 # The savings variable is for the purposes of calculating how much deposit, it's not part of the kiwisaver legislation -class savings__kiwisaver(Variable): +class kiwisaver__savings(Variable): value_type = float entity = Person definition_period = MONTH label = u"Personal cash savings in bank" -class homestart_deposit_eligible(Variable): +class kiwisaver__homestart_deposit_eligible(Variable): value_type = float entity = Person definition_period = MONTH label = u"Deposit amount needed to be eligble for homestart grant" def formula(persons, period): - return persons('total_savings__kiwisaver', period) >= persons('homestart_deposit_req__kiwisaver', period) + return persons('kiwisaver__total_savings', period) >= persons('homestart_deposit_req__kiwisaver', period) -class lvr_deposit_eligible(Variable): +class kiwisaver__lvr_deposit_eligible(Variable): value_type = float entity = Person definition_period = MONTH label = u"Deposit amount needed to be eligble for homestart grant" def formula(persons, period): - return persons('total_savings__kiwisaver', period) >= persons('lvr_deposit_req__kiwisaver', period) + return persons('kiwisaver__total_savings', period) >= persons('kiwisaver__lvr_deposit_req', period) -class indv_income_per_hs_grant(Variable): +class kiwisaver__individual_income_per_homestart_grant(Variable): value_type = int entity = Person definition_period = YEAR @@ -135,7 +135,7 @@ class indv_income_per_hs_grant(Variable): # Check how to set input by user and check against the threshold -class combined_income_per_hs_grant(Variable): +class kiwisaver__combined_income_per_hs_grant(Variable): value_type = int entity = Person definition_period = YEAR From ca65513017a3d17c6ca5f5e8de1bcb14e2fb40ba Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 1 Jun 2018 16:03:45 +1200 Subject: [PATCH 16/16] More variable consistency --- openfisca_aotearoa/tests/kiwisaver.yaml | 16 ++++++++-------- openfisca_aotearoa/variables/kiwisaver.py | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/openfisca_aotearoa/tests/kiwisaver.yaml b/openfisca_aotearoa/tests/kiwisaver.yaml index 3df1e0e1..6d4db1f9 100644 --- a/openfisca_aotearoa/tests/kiwisaver.yaml +++ b/openfisca_aotearoa/tests/kiwisaver.yaml @@ -2,30 +2,30 @@ period: 2018-01 absolute_error_margin: 0 input_variables: - contrib_duration__kiwisaver: 2 + kiwisaver__contrib_duration: 2 output_variables: - homestart_grant__kiwisaver: 0 + kiwisaver__homestart_grant: 0 - name: If contributed for 3 years, entitled to $3000 period: 2018-01 absolute_error_margin: 0 input_variables: - contrib_duration__kiwisaver: 3 + kiwisaver__contrib_duration: 3 output_variables: - homestart_grant__kiwisaver: 3000 + kiwisaver__homestart_grant: 3000 - name: If contributed for 4 years, entitled to $4000 period: 2018-01 absolute_error_margin: 0 input_variables: - contrib_duration__kiwisaver: 4 + kiwisaver__contrib_duration: 4 output_variables: - homestart_grant__kiwisaver: 4000 + kiwisaver__homestart_grant: 4000 - name: If contributed for over 5 years, entitled to $5000 period: 2018-01 absolute_error_margin: 0 input_variables: - contrib_duration__kiwisaver: 7 + kiwisaver__contrib_duration: 7 output_variables: - homestart_grant__kiwisaver: 5000 \ No newline at end of file + kiwisaver__homestart_grant: 5000 \ No newline at end of file diff --git a/openfisca_aotearoa/variables/kiwisaver.py b/openfisca_aotearoa/variables/kiwisaver.py index b1d0f2b6..e8374f00 100644 --- a/openfisca_aotearoa/variables/kiwisaver.py +++ b/openfisca_aotearoa/variables/kiwisaver.py @@ -33,7 +33,7 @@ def formula(persons, period): return persons('kiwisaver__contrib_duration', period) >= 3 -class homestart_grant__kiwisaver(Variable): +class kiwisaver__homestart_grant(Variable): value_type = float entity = Person definition_period = MONTH @@ -79,7 +79,7 @@ class kiwisaver__total_savings(Variable): label = u"Homestart grant deposit requirement" def formula(persons, period): - return persons('kiwisaver__savings', period) + persons('homestart_grant__kiwisaver', period) + persons('kiwisaver__net', period) + return persons('kiwisaver__savings', period) + persons('kiwisaver__homestart_grant', period) + persons('kiwisaver__net', period) class kiwisaver__gross(Variable):