Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Add Home Grant and Kiwisaver #17

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
db62b68
add citizenship variable
May 19, 2018
d0dd21e
added kiwisaver.py and 3 variables
JudyPuff May 19, 2018
3ec3a4b
added 2 yaml files under parameters
JudyPuff May 19, 2018
f868d33
added prop_threshold yamls and more classes in kiwisaver variable
JudyPuff May 19, 2018
0841171
added formula for hs_grant calculation based on years of contribution
JudyPuff May 20, 2018
4b74409
added kiwisaver parameters and variables with Hamish
JudyPuff May 23, 2018
7d68fb9
Merge branch 'master' into kiwisaver
Br3nda May 29, 2018
596b574
Pep8 fixes
Br3nda May 29, 2018
adedacf
Removed unused import
Br3nda May 29, 2018
9d07eac
Renamed class - meets contrib duration requirement
Br3nda May 29, 2018
73e130a
Rename variales in test to have __kiwisaver
Br3nda May 29, 2018
740b954
Matching test variables to the python
Br3nda May 29, 2018
cb8c06f
Fixing more variable names
Br3nda May 29, 2018
f918a83
Rename purc_price to purchase_price
Br3nda May 29, 2018
428eaae
Merge branch 'master' into kiwisaver
Br3nda Jun 1, 2018
3d89969
Merge remote-tracking branch 'origin/master' into kiwisaver
Br3nda Jun 1, 2018
cf586c0
Clearer variable name
Br3nda Jun 1, 2018
4cb79f9
Merge branch 'kiwisaver' of github.com:ServiceInnovationLab/openfisca…
Br3nda Jun 1, 2018
eeb0fac
Merge branch 'bw/kiwisaver' into kiwisaver
Br3nda Jun 1, 2018
7ba8673
refactor - rename variable to have kiwisaver at start
Br3nda Jun 1, 2018
ca65513
More variable consistency
Br3nda Jun 1, 2018
bdf9a61
Merge branch 'master' into kiwisaver
Br3nda Nov 10, 2018
b0816f9
Merge branch 'master' into kiwisaver
Br3nda May 20, 2019
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
description: Property price threshold to be eligible for the Homestart grant for Auckland
reference:
values:
2006-01: # find date this was set
value: 600000
Original file line number Diff line number Diff line change
@@ -0,0 +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:
2006-01: #find the date this was set
value: 85000
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
description: Length of contribution to kiwisaver account
reference: "http://www.legislation.govt.nz/act/public/2006/0040/latest/DLM379487.html#DLM379487"
values:
2006-01:
value: 3
#need to do more research under s8 Schedule 1 of the Kiwisaver Act
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
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:
2006-01: # find date this was set
value: 500000
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
description: Property price threshold to be eligible for the Homestart grant for the rest of NZ
reference:
values:
2006-01: # find date this was set
value: 400000
31 changes: 31 additions & 0 deletions openfisca_aotearoa/tests/kiwisaver.yaml
Original file line number Diff line number Diff line change
@@ -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:
kiwisaver__contrib_duration: 2
output_variables:
kiwisaver__homestart_grant: 0

- name: If contributed for 3 years, entitled to $3000
period: 2018-01
absolute_error_margin: 0
input_variables:
kiwisaver__contrib_duration: 3
output_variables:
kiwisaver__homestart_grant: 3000

- name: If contributed for 4 years, entitled to $4000
period: 2018-01
absolute_error_margin: 0
input_variables:
kiwisaver__contrib_duration: 4
output_variables:
kiwisaver__homestart_grant: 4000

- name: If contributed for over 5 years, entitled to $5000
period: 2018-01
absolute_error_margin: 0
input_variables:
kiwisaver__contrib_duration: 7
output_variables:
kiwisaver__homestart_grant: 5000
12 changes: 12 additions & 0 deletions openfisca_aotearoa/variables/general.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# 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"
145 changes: 145 additions & 0 deletions openfisca_aotearoa/variables/kiwisaver.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
# -*- 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
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 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 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 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('kiwisaver__contrib_duration', period) >= 3


class kiwisaver__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):
HS_grant = persons('kiwisaver__duration', period) * \
persons('kiwisaver__contrib_duration', period) * 1000
return clip(HS_grant, 0, 5000)


class kiwisaver__purchase_price(Variable):
value_type = int
entity = Person
definition_period = YEAR
label = u"Purchase price of the proposed home"


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('kiwisaver__purchase_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('kiwisaver__purchase_price', period) * 0.1


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('kiwisaver__savings', period) + persons('kiwisaver__homestart_grant', period) + persons('kiwisaver__net', period)


class kiwisaver__gross(Variable):
value_type = float
entity = Person
definition_period = MONTH
label = u"Gross kiwi saver balance"


class kiwisaver__net(Variable):
value_type = float
entity = Person
definition_period = MONTH
label = u"Gross kiwi saver balance"

def formula(persons, period):
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 kiwisaver__savings(Variable):
value_type = float
entity = Person
definition_period = MONTH
label = u"Personal cash savings in bank"


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('kiwisaver__total_savings', period) >= persons('homestart_deposit_req__kiwisaver', period)


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('kiwisaver__total_savings', period) >= persons('kiwisaver__lvr_deposit_req', period)


class kiwisaver__individual_income_per_homestart_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 kiwisaver__combined_income_per_hs_grant(Variable):
value_type = int
entity = Person
definition_period = 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"