diff --git a/openfisca_aotearoa/definitions/earnings_as_an_employee.md b/openfisca_aotearoa/definitions/earnings_as_an_employee.md new file mode 100644 index 00000000..d17223dc --- /dev/null +++ b/openfisca_aotearoa/definitions/earnings_as_an_employee.md @@ -0,0 +1,15 @@ +# DEFINITIONS: EARNINGS AS AN EMPLOYEE + +**Term name:** EarningsAsAnEmployee + +**UUID:** organiccoders/brk:/1234/ed84652e-8011-43dc-aeef-72e5ad3593f4 + +**Definition:** Earnings as an employee, in relation to any person and any tax year, means all PAYE income payments of the person for the tax year. + +**Legislation:** Schedule 2/Part1/5 Compensation for Live Organ Donors Act 2016 + +**Refers to:** earnings as an employee has the meaning given by section 6(1) of the Accident Compensation Act 2001 + +**Narrower than:** ‘Earnings’ + +**Related:** ‘Employee’ \ No newline at end of file diff --git a/openfisca_aotearoa/definitions/number_of_weeks.md b/openfisca_aotearoa/definitions/number_of_weeks.md new file mode 100644 index 00000000..e985e4ba --- /dev/null +++ b/openfisca_aotearoa/definitions/number_of_weeks.md @@ -0,0 +1,15 @@ +# DEFINITIONS: NUMBER OF WEEKS + +**Term name:** NumberOfWeeks + +**UUID:** organiccoders/brk:/1234/12a0780a-b516-44f1-bdb7-6ec4b6c3e174 + +**Definition:** number of weeks is (a) the number of full weeks plus any part week (expressed as a portion of a week), if the period is 1 week or more; and (b) a part week (expressed as a portion of a week), if the period is less than 1 week + +**Legislation:** Part 1, Section 4 + +**Narrower than:** http://purl.org/dc/terms/LocationPeriodOrJurisdiction + +**Related:** PeriodOfTime (altLabel:Period) + +**Note:** Time event (ref DCAT temporal purl.org/dc/terms/temporal) or CPSV ‘period of time’ An interval of time that is named or defined by its start and end dates. http://purl.org/dc/terms/PeriodOfTime \ No newline at end of file diff --git a/openfisca_aotearoa/tests/live_organ_donor_compensation.yaml b/openfisca_aotearoa/tests/live_organ_donor_compensation.yaml new file mode 100644 index 00000000..74088b59 --- /dev/null +++ b/openfisca_aotearoa/tests/live_organ_donor_compensation.yaml @@ -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 \ No newline at end of file diff --git a/openfisca_aotearoa/variables/live_organ_donor_compensation.py b/openfisca_aotearoa/variables/live_organ_donor_compensation.py new file mode 100644 index 00000000..2512ad8f --- /dev/null +++ b/openfisca_aotearoa/variables/live_organ_donor_compensation.py @@ -0,0 +1,135 @@ +# -*- 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 + entity = Person + definition_period = YEAR # TODO - determine whether we need to get WEEK to work + label = u"The amount deducted as a kiwisaver contribution" + # 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 = "https://github.com/OrganicCoders/openfisca-aotearoa/blob/master/openfisca_aotearoa/definitions/earnings_as_an_employee.md" + 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 = "https://github.com/OrganicCoders/openfisca-aotearoa/blob/master/openfisca_aotearoa/definitions/number_of_weeks.md" + 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" + 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" + definition_period = YEAR