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

Refactor and add missing income tests #59

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
48 changes: 48 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,53 @@
# Changelog

## 21.0.0 - [59](https://github.com/digitalaotearoa/openfisca-aotearoa/pull/59)

* Tax and benefit system evolution.
* Impacted periods: all.
* Impacted areas: `sole_parent_support`, `jobseeker_support`
* Details:
- Add `income_test_n` as the result of applying an income test to a benefit.

#### Discussion

Main benefits are income-tested (subject to an abatement rate based on income).
Non-main benefits can be income-tested via main benefits (i.e. accommodation
supplement via jobseeker). However, some benefits change the definitions of
certain things, i.e. income is not the same for accommodation supplement and
for jobseeker support. Furthermore, the notion of income-tested benefit has
been replaced with that of main benefit, which can create confusion when a
benefit like accommodation supplement is income-tested via jobseeker support.

This poses a challenge to the rule-maker, because in order to define a general
rule for an income test, that applies to benefits with different definitions of
income, it has to make it _high order_. In plain English, it has to create a
_rule factory_. A rule that creates a rule, depending on the context of its
application (i.e. the benefit it is applied to).

There are several ways to solve this problem, yet all gravitate around two
philosophies:

1. Stick to the letter: if the rule-maker defines a _pure high-order function_
that can't be applied directly, one solution is to just model it as close to
the letter that is possible.

2. Incorporate: if the rule can't be applied directly, ignore it, and
incorporate it as many times as is used without abstracting it into a rule
the way the rule-maker did (cf. copy-paste several times).

Currently the OpenFisca DSL does not provide any native way of modelling this
cases, as it is assumed as an invariant that, what can be modelled, can be
directly applied at definition time (just following the text), and not at
run time (depending on the context it is being applied).

As usually the law doesn't contain this kind of abstractions, their use has
always been discouraged as _not being truthful to the text_ or _modelling as a
developer and not as a policy folk_. This case is, then, peculiar.

The solution adopted here is to model the income test as a normal `Variable`,
and capturing the context of its application from the stack. While it works,
it is not a very elegant solution, and it is likely error-prone.

### 20.1.1 - [48](https://github.com/digitalaotearoa/openfisca-aotearoa/pull/48)

* Test case.
Expand Down
6 changes: 2 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -275,12 +275,10 @@ This project currently utilises one specific pattern however for benefit calcula
- `jobseeker_support__entitled` (true/false) - or - `jobseeker_support__eligible` (true/false)
- `jobseeker_support__base` (float)
- `jobseeker_support__cutoff` (float)
- `jobseeker_support__reduction` (float)
- `jobseeker_support__abatement` (float)
- `jobseeker_support__benefit` (float)

i.e. the formula for `jobseeker_support__benefit` would be:
```
jobseeker_support__entitled * min(jobseeker_support__base - jobseeker_support__reduction, jobseeker_support__cutoff)
jobseeker_support__entitled * min(jobseeker_support__base - jobseeker_support__abatement, jobseeker_support__cutoff)
```


Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
description: Social Security Income Test 1
description: >
Social Security Act 2018 -
Schedule 2 Dictionary -
Income test 1 -
The applicable rate of benefit must be reduced—
(a) by 30 cents for every $1 of the total income of the beneficiary and
the beneficiary’s spouse or partner that is more than $160 a week but
not more than $250 a week
(b) by 70 cents for every $1 of that income that is more than $250 a week
metadata:
# currency or /1 (rate) or year (never used)
unit: currency
# single_amount or marginal_rate or marginal_amount or value?
type: value
type: marginal_rate
rate_unit: /1
threshold_unit: currency-NZD
reference:
2018-11-26:
title: Social Security Act 2018 (as enacted)
Expand All @@ -17,33 +24,43 @@ metadata:
brackets:
- rate:
2018-11-26:
value: 0
value: 0.0
2020-04-01:
value: 0.0
2021-04-01:
value: 0.0
threshold:
2018-11-26:
value: 0
2020-04-01:
value: 0
2021-04-01:
value: 0
- rate:
2018-11-26:
value: 0.3
2020-04-01:
value: 0.3
2021-04-01:
value: 0.3
threshold:
2018-11-26:
value: 100
2020-04-01:
value: 115
2021-04-01:
value: 160
# no change in 2022
# no change in 2023
# https://www.legislation.govt.nz/all/results.aspx?search=ad_act%40bill%40regulation%40deemedreg__%22Income+Test+1%22____25_ac%40bc%40rc%40dc%40apub%40aloc%40apri%40apro%40aimp%40bgov%40bloc%40bpri%40bmem%40rpub%40rimp_ac%40bc%40rc%40ainf%40anif%40bcur%40rinf%40rnif%40raif%40rasm%40rrev_a_aw_se_&p=1
- rate:
2018-11-26:
value: 0.7
2020-04-01:
value: 0.7
2021-04-01:
value: 0.7
threshold:
2018-11-26:
value: 200
2020-04-01:
value: 215
2021-04-01:
value: 250
# no change in 2022
# no change in 2023
# https://www.legislation.govt.nz/all/results.aspx?search=ad_act%40bill%40regulation%40deemedreg__%22Income+Test+1%22____25_ac%40bc%40rc%40dc%40apub%40aloc%40apri%40apro%40aimp%40bgov%40bloc%40bpri%40bmem%40rpub%40rimp_ac%40bc%40rc%40ainf%40anif%40bcur%40rinf%40rnif%40raif%40rasm%40rrev_a_aw_se_&p=1
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
description: Social Security Income Test 2
description: >
Social Security Act 2018 -
Schedule 2 Dictionary -
Income test 2 -
The applicable rate of benefit must be reduced—
(a) by 15 cents for every $1 of the total income of the beneficiary and
the beneficiary’s spouse or partner that is more than $160 a week but
not more than $250 a week; and
(b) by 35 cents for every $1 of that income that is more than $250 a week
metadata:
# currency or /1 (rate) or year (never used)
unit: currency
# single_amount or marginal_rate or marginal_amount or value?
type: value
type: marginal_rate
rate_unit: /1
threshold_unit: currency-NZD
reference:
2018-11-26:
title: Social Security Act 2018 (as enacted)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
description: Social Security Income Test 3b
description: >
Social Security Act 2018 -
Schedule 2 Dictionary -
Income test 3 b -
The applicable rate of benefit must be reduced by 70 cents for every $1 of
total income of the beneficiary and the beneficiary’s spouse or partner
that is more than,— [...]
(b) in any other case, $160 a week
metadata:
# currency or /1 (rate) or year (never used)
unit: currency
# single_amount or marginal_rate or marginal_amount or value?
type: value
type: marginal_rate
rate_unit: /1
threshold_unit: currency-NZD
reference:
2018-11-26:
title: Social Security Act 2018 (as enacted)
Expand Down Expand Up @@ -31,10 +37,3 @@ brackets:
value: 90
2021-04-01:
value: 160
# Income Test 3 means that the applicable rate of benefit must be reduced by 70
# cents for every $1 of total income of the beneficiary and the beneficiary’s
# spouse or partner that is more than,—
# (a) if the rate of benefit is a rate of New Zealand superannuation stated in
# clause 1 of Part 2 of Schedule 1 of the New Zealand Superannuation and
# Retirement Income Act 2001, $160 a week; or
# (b) in any other case, $160 a week
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
description: Social Security Income Test 4
description: >
Social Security Act 2018 -
Schedule 2 Dictionary -
Income test 4 -
The applicable rate of benefit must be reduced by 35 cents for every $1 of
the total income of the beneficiary and the beneficiary’s spouse or partner
that is more than $160 a week
metadata:
# currency or /1 (rate) or year (never used)
unit: currency
# single_amount or marginal_rate or marginal_amount or value?
type: value
type: marginal_rate
rate_unit: /1
threshold_unit: currency-NZD
reference:
2018-11-26:
title: Social Security Act 2018 (as enacted)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
- name: >
Social Security Act 2018 -
Schedule 2 Dictionary -
Income test 1 -
The applicable rate of benefit must be reduced—
(a) by 30 cents for every $1 of the total income of the beneficiary and
the beneficiary’s spouse or partner that is more than $160 a week but
not more than $250 a week
(b) by 70 cents for every $1 of that income that is more than $250 a week
period: 2018-11-26
input:
jobseeker_support__income:
2023-W01: [159.99, 160.00, 160.01, 161.99, 249.99, 250.00, 250.01, 251.99]
schedule_4__part1_1_c:
2023-W01: [true, true, true, true, true, true, true, true]
output:
jobseeker_support__abatement:
2023-W01: [0, 0, 0, 0.30, 26.70, 27.00, 27.00, 27.70]


- name: >
Social Security Act 2018 -
Schedule 2 Dictionary -
Income test 3 -
The applicable rate of benefit must be reduced by 70 cents for every $1 of
the total income of the beneficiary and the beneficiary’s spouse or partner
that is more than,—
(b) [...] $160 a week
period: 2018-11-26
input:
jobseeker_support__income:
2023-W01: [159.99, 160.00, 160.01, 161.99, 249.99, 250.00, 250.01, 251.99]
schedule_4__part1_1_a:
2023-W01: [true, true, true, true, true, true, true, true]
output:
jobseeker_support__abatement:
2023-W01: [0, 0, 0, 0.70, 62.30, 63.00, 63.00, 63.70]


- name: >
Social Security Act 2018 -
Schedule 2 Dictionary -
Income test 4 -
The applicable rate of benefit must be reduced by 35 cents for every $1 of
the total income of the beneficiary and the beneficiary’s spouse or partner
that is more than $160 a week
period: 2018-11-26
input:
jobseeker_support__income:
2023-W01: [159.99, 160.00, 160.01, 161.99, 249.99, 250.00, 250.01, 251.99]
schedule_4__part1_1_d:
2023-W01: [false, false, false, false, false, false, false, false]
schedule_4__part1_1_g:
2023-W01: [true, true, true, true, true, true, true, true]
output:
jobseeker_support__abatement:
2023-W01: [0, 0, 0, 0.35, 31.15, 31.50, 31.50, 31.85]
schedule_4__part1_1_d:
2023-W01: [false, false, false, false, false, false, false, false]
Original file line number Diff line number Diff line change
Expand Up @@ -216,13 +216,6 @@
2022-W01: [240.65, 406.78, 239.70]
2023-W01: [283.00, 440.96, 274.37]
2023-W15: [303.43, 472.79, 294.18]
jobseeker_support__reduction:
2020-W01: [143.5, 0, 0]
2021-W01: [59.5, 0, 0]
2021-W23: [0, 0, 0]
2022-W01: [138.6, 0, 0]
2023-W01: [31.5, 0, 0]
2023-W15: [31.5, 0, 0]
jobseeker_support__benefit:
2020-W01: [52, 0, 0]
2021-W01: [154.53, 0, 0]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
- name: >
Social Security Act 2018 -
Schedule 2 Dictionary -
Income test 1-4 -
The applicable rate of benefit must be reduced [...] of the total income of
the beneficiary and the beneficiary’s spouse or partner.
period: 2018-11-26
input:
persons:
Vrenda:
social_security__income:
2023-W01: 0
2023-W02: 100
2023-W03: 100
Piedad:
social_security__income:
2023-W01: 0
2023-W02: 0
2023-W03: 100
output:
jobseeker_support__income:
2023-W01: [0, 0]
2023-W02: [100, 0]
2023-W03: [100, 100]


- name: >
Social Security Act 2018 -
Schedule 2 Dictionary -
Income test 1-4 -
The applicable rate of benefit must be reduced [...] of the total income of
the beneficiary and the beneficiary’s spouse or partner.
period: 2018-11-26
input:
persons:
Vrenda:
social_security__income:
2023-W01: 0
2023-W02: 100
2023-W03: 100
Piedad:
social_security__income:
2023-W01: 0
2023-W02: 0
2023-W03: 100
family:
principal: Vrenda
partners: [Piedad]
output:
jobseeker_support__income:
2023-W01: [0, 0]
2023-W02: [100, 100]
2023-W03: [200, 200]
Empty file.
Empty file.
Empty file.
Loading