-
Notifications
You must be signed in to change notification settings - Fork 19
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 organ donor compensation #16
base: master
Are you sure you want to change the base?
Changes from 21 commits
7818fa5
0d6a6f7
fbe6036
cc92a5c
090f12d
2cd9f23
6800008
2995ce2
0f810b5
b472181
b2d7db2
dbbfcf6
bc00352
36822d7
b958b43
e68ff34
0c7ee37
067d5cb
f138396
429becd
2e507ed
82a8810
d78b98f
2aaaf2b
5fbe05f
64c5842
74b15f3
21e69e5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# We can run this test on our command line using `openfisca-run-test openfisca_aotearoa/tests/live_organ_donor_compensation.yaml` | ||
|
||
- name: An employee with earnings for the last 52 weeks not enrolled in Kiwisaver, no ACC payment in past year | ||
period: 2018 | ||
absolute_error_margin: 0.0001 | ||
input_variables: | ||
sum_of_earnings_in_last_52_weeks: 62500 | ||
earnings_period_in_weeks: 52 | ||
output_variables: | ||
weekly_compensation_before_tax: 1201.92 | ||
|
||
- name: An employee with earnings for the last 20 weeks not enrolled in Kiwisaver, no ACC payment in past year | ||
period: 2018 | ||
absolute_error_margin: 0.0001 | ||
input_variables: | ||
sum_of_earnings_in_last_52_weeks: 30000 | ||
earnings_period_in_weeks: 20 | ||
output_variables: | ||
weekly_compensation_before_tax: 1500 | ||
|
||
- name: An employee with earnings for the last 52 weeks not enrolled in Kiwisaver, with ACC over 6 weeks | ||
period: 2018 | ||
absolute_error_margin: 0.0001 | ||
input_variables: | ||
sum_of_earnings_in_last_52_weeks: 62500 | ||
earnings_period_in_weeks: 52 | ||
sum_of_earnings_during_compensation_period_in_last_52_weeks: 6000 | ||
compensation_period_in_weeks: 6 | ||
output_variables: | ||
weekly_compensation_before_tax: 1228.26 | ||
|
||
- name: An employee with earnings for the last 26 weeks with 4% Kiwisaver, no ACC payment in last year | ||
period: 2018 | ||
absolute_error_margin: 0.0001 | ||
input_variables: | ||
sum_of_earnings_in_last_52_weeks: 26000 | ||
earnings_period_in_weeks: 26 | ||
kiwisaver_employee_deduction_percentage: 4 | ||
output_variables: | ||
weekly_compensation_before_tax: 1000 | ||
kiwisaver_employee_deduction: 40 | ||
|
||
- name: A person who was both employed and self-employed in the previous year; not enrolled in Kiwisaver, no ACC payment in last year | ||
period: 2018 | ||
absolute_error_margin: 0.0001 | ||
input_variables: | ||
sum_of_earnings_in_last_52_weeks: 20200 | ||
# earnings_period_in_weeks: 52 | ||
sum_of_self_employed_earnings_in_most_recently_completed_tax_year: 30300 | ||
number_of_weeks_in_most_recently_completed_tax_year: 53 | ||
output_variables: | ||
weekly_compensation_before_tax: 960.16 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
# -*- 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 round | ||
|
||
class weekly_compensation_before_tax(Variable): | ||
""" | ||
Calculate the weekly compensation based on employee earnings over the last 52 weeks | ||
and self-employed earnings in most recent tax year. | ||
This relies on the user totalling the earnings over the last 52 weeks and the earnings period in weeks. | ||
Ideally a user would be able to enter the earnings per week (over a period) and the totals would then | ||
be calculated. | ||
""" | ||
value_type = float | ||
entity = Person | ||
definition_period = YEAR # TODO - determine whether we need to get WEEK to work | ||
label = u"The amount payable as compensation per week before tax" | ||
# note that this also implements http://www.legislation.govt.nz/act/public/2016/0096/latest/whole.html?search=ts_act%40bill%40regulation%40deemedreg_live+organ_resel_25_a#DLM6965116 | ||
reference = "http://www.legislation.govt.nz/act/public/2016/0096/latest/whole.html?search=ts_act%40bill%40regulation%40deemedreg_live+organ_resel_25_a#DLM6965123" | ||
|
||
def formula(persons, period, parameters): | ||
earnings_amount = persons('sum_of_earnings_in_last_52_weeks', period) | ||
compensation_amount = persons('sum_of_earnings_during_compensation_period_in_last_52_weeks', period) | ||
earnings_excluding_compensation_amount = earnings_amount - compensation_amount | ||
|
||
earnings_period = persons('earnings_period_in_weeks', period) | ||
compensation_period = persons('compensation_period_in_weeks', period) | ||
earnings_excluding_compensation_period = earnings_period - compensation_period | ||
|
||
self_employed_earnings_in_most_recent_tax_year = persons('sum_of_self_employed_earnings_in_most_recently_completed_tax_year', period) | ||
most_recent_tax_year_period = persons('number_of_weeks_in_most_recently_completed_tax_year', period) | ||
|
||
employee_weekly_earnings = earnings_excluding_compensation_amount / earnings_excluding_compensation_period | ||
self_employed_weekly_earnings = self_employed_earnings_in_most_recent_tax_year / most_recent_tax_year_period | ||
|
||
return round(employee_weekly_earnings + self_employed_weekly_earnings, 2) | ||
|
||
class kiwisaver_employee_deduction(Variable): | ||
value_type = float | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This method might be better in a KiwiSaver specific module, so that it picks up any changes to KiwiSaver. It's also largely copy and paste from above. It should utilise the method from above to calculate the basic compensation and then calculate KiwiSaver on that amount. It is also missing concepts such as KiwiSaver holiday period. |
||
entity = Person | ||
definition_period = YEAR # TODO - determine whether we need to get WEEK to work | ||
label = u"The amount deducted as a kiwisaver contribution" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed |
||
# Salary or wages includes a payment of earnings compensation under the Compensation for Live Organ Donors Act 2016; | ||
# Ref: http://www.legislation.govt.nz/act/public/2007/0097/latest/DLM1519947.html?search=ts_act%40bill%40regulation%40deemedreg_live+organ_resel_25_a#DLM1519947 | ||
# KiwiSaver deductions: | ||
reference = "http://www.legislation.govt.nz/act/public/2006/0040/latest/whole.html?search=ts_act%40bill%40regulation%40deemedreg_live+organ_resel_25_a#DLM379040" | ||
|
||
def formula(persons, period, parameters): | ||
earnings_amount = persons('sum_of_earnings_in_last_52_weeks', period) | ||
compensation_amount = persons('sum_of_earnings_during_compensation_period_in_last_52_weeks', period) | ||
earnings_excluding_compensation_amount = earnings_amount - compensation_amount | ||
|
||
earnings_period = persons('earnings_period_in_weeks', period) | ||
compensation_period = persons('compensation_period_in_weeks', period) | ||
earnings_excluding_compensation_period = earnings_period - compensation_period | ||
|
||
self_employed_earnings_in_most_recent_tax_year = persons('sum_of_self_employed_earnings_in_most_recently_completed_tax_year', period) | ||
most_recent_tax_year_period = persons('number_of_weeks_in_most_recently_completed_tax_year', period) | ||
|
||
employee_weekly_earnings = earnings_excluding_compensation_amount / earnings_excluding_compensation_period | ||
self_employed_weekly_earnings = self_employed_earnings_in_most_recent_tax_year / most_recent_tax_year_period | ||
|
||
weekly_compensation = round(employee_weekly_earnings + self_employed_weekly_earnings, 2) | ||
|
||
kiwisaver_employee_deduction_percentage = persons('kiwisaver_employee_deduction_percentage', period) | ||
return round(weekly_compensation * kiwisaver_employee_deduction_percentage / 100, 2) | ||
|
||
class kiwisaver_member(Variable): | ||
value_type = bool | ||
default_value = True | ||
entity = Person | ||
label = u"Whether the person currently pays into Kiwisaver" | ||
definition_period = YEAR | ||
|
||
class sum_of_earnings_in_last_52_weeks(Variable): | ||
value_type = float | ||
entity = Person | ||
label = u"Total earnings over last 52 weeks" | ||
reference = "http://organiccoders.allengeer.com/brk-1234-abcdfcrg234356/" | ||
definition_period = YEAR | ||
|
||
class earnings_period_in_weeks(Variable): | ||
value_type = int | ||
default_value = 52 | ||
entity = Person | ||
label = u"The number of weeks over which earnings have been earned" | ||
reference = "http://organiccoders.allengeer.com/definitions-number-of-weeks/" | ||
definition_period = YEAR | ||
|
||
class sum_of_earnings_during_compensation_period_in_last_52_weeks(Variable): | ||
value_type = float | ||
entity = Person | ||
label = u"Earnings during the period in which the donor was entitled to weekly compensation (as defined in section 6(1) of the Accident Compensation Act 2001)" | ||
definition_period = YEAR | ||
|
||
class compensation_period_in_weeks(Variable): | ||
value_type = int | ||
entity = Person | ||
label = u"The number of weeks in which the donor was entitled to weekly compensation (as defined in section 6(1) of the Accident Compensation Act 2001) over the last 52 weeks" | ||
definition_period = YEAR | ||
|
||
class sum_of_self_employed_earnings_in_most_recently_completed_tax_year(Variable): | ||
value_type = float | ||
default_value = 0 | ||
entity = Person | ||
label = u"Self-employed earnings during the period in which the donor was entitled to weekly compensation (as defined in section 6(1) of the Accident Compensation Act 2001)" | ||
definition_period = YEAR | ||
|
||
class number_of_weeks_in_most_recently_completed_tax_year(Variable): | ||
value_type = int | ||
default_value = 52 | ||
entity = Person | ||
label = u"The number of weeks in the most recently completed tax year" | ||
definition_period = YEAR | ||
|
||
class kiwisaver_employee_deduction_percentage(Variable): | ||
value_type = int | ||
default_value = 0 | ||
entity = Person | ||
label = u"Kiwisaver employee deduction percentage " | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Extra space in end of string here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed, thanks |
||
definition_period = YEAR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this comment still relevant? It seems this code works well with
YEAR
, even though it would be more proper withWEEK
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the current scheme, ETERNITY may be better since the value doesn't correspond to a specific MONTH or YEAR.
I think the value actually corresponds to a particular point in time corresponding to the date of the latest pay period that has been used in the calculation.