Skip to content
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
7818fa5
First basic test
nigelcharman May 19, 2018
0d6a6f7
Added tax code and after tax amount
nigelcharman May 19, 2018
fbe6036
Commented out tax implications
nigelcharman May 19, 2018
cc92a5c
Initial test passing
nigelcharman May 19, 2018
090f12d
Tidy up
nigelcharman May 19, 2018
2cd9f23
Merge pull request #2 from OrganicCoders/tests
nigelcharman May 19, 2018
6800008
Changed to 52 week calculation
nigelcharman May 19, 2018
2995ce2
Merge branch 'tests'
nigelcharman May 19, 2018
0f810b5
Applied rounding, commented out unneeded code
nigelcharman May 19, 2018
b472181
Added subpart 1 5(3) compensation earnings disregarded
nigelcharman May 19, 2018
b2d7db2
Added self-employed earnings
nigelcharman May 19, 2018
dbbfcf6
Added kiwisaver
nigelcharman May 19, 2018
bc00352
Added reference to definition
nigelcharman May 20, 2018
36822d7
Added reference to definition
nigelcharman May 20, 2018
b958b43
Update live_organ_donor_compensation.py
allengeer May 20, 2018
e68ff34
Merge pull request #3 from allengeer/patch-1
nigelcharman May 20, 2018
0c7ee37
Removed commented out code
nigelcharman May 21, 2018
067d5cb
Added references to legislation
nigelcharman May 21, 2018
f138396
Fixed comments and removed kiwisaver_member variable
nigelcharman May 21, 2018
429becd
Merge branch 'master' of github.com:OrganicCoders/openfisca-aotearoa
nigelcharman May 21, 2018
2e507ed
Added docstring comment
nigelcharman May 21, 2018
82a8810
Fixed formatting so tests pass when using 'make test'
nigelcharman May 21, 2018
d78b98f
Added reference to KiwiSaver rate
nigelcharman May 21, 2018
2aaaf2b
Removed space at end of string
nigelcharman May 21, 2018
5fbe05f
Added definitions of 'number of weeks' and 'earnings as an employee'
nigelcharman May 23, 2018
64c5842
Updated references to definitions
nigelcharman May 23, 2018
74b15f3
Merge pull request #4 from OrganicCoders/data-definitions
nigelcharman May 23, 2018
21e69e5
Updated references to definitions on master branch
nigelcharman May 23, 2018
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
23 changes: 23 additions & 0 deletions openfisca_aotearoa/tests/live_organ_donor_compensation.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# We can run this test on our command line using `openfisca-run-test openfisca_aotearoa/tests/live_organ_donor_compensation.yaml`

- name: An employee earning mixed salary 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
kiwisaver_member: no
output_variables:
weekly_compensation_before_tax: 1201.92

- name: An employee earning mixed salary 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
kiwisaver_member: no
output_variables:
weekly_compensation_before_tax: 1228.26
73 changes: 73 additions & 0 deletions openfisca_aotearoa/variables/live_organ_donor_compensation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# -*- 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):
value_type = float
entity = Person
definition_period = YEAR # TODO - determine whether we need to get WEEK to work
Copy link
Copy Markdown
Member Author

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 with WEEK.

Copy link
Copy Markdown

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.

label = u"The amount payable as compensation per week before tax"
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
return round(earnings_excluding_compensation_amount / earnings_excluding_compensation_period , 2)

# class PayFrequency(Enum):
# weekly = u'Weekly'
# fortnightly = u'Fortnightly'
# four_weekly = u'Four Weekly'
# monthly = u'Monthly'

# class pay_frequency(Variable):
# value_type = Enum
# possible_values = PayFrequency
# default_value = PayFrequency.weekly # The default is mandatory
# entity = Person
# definition_period = YEAR
# label = u"The frequency at which a person is paid"

# class salary_per_pay(Variable):
# value_type = float
# entity = Person
# definition_period = YEAR # TODO - determine whether we need to get WEEK to work
# label = u"The salary earned by a person before tax"
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Version control (Git) can help us recover code if we need it, but commented-out code usually becomes a problem over time as we cannot know if it is still up-to-date or not… Could we maybe remove these parts from the model? 🤔


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"
definition_period = YEAR

class earnings_period_in_weeks(Variable):
value_type = int
entity = Person
label = u"The number of weeks over which earnings have been earned"
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