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] Use fortnights for parenting allowance #106

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ install: deps
@# `make install` installs the editable version of OpenFisca-France.
@# This allows contributors to test as they code.
pip install -e '.[dev]' --upgrade --use-deprecated=legacy-resolver
pip install --editable git+https://github.com/openfisca/openfisca-core.git@add-weeks#egg=OpenFisca-Core[web-api] # use a specific branch of OpenFisca-Core
Copy link
Contributor

Choose a reason for hiding this comment

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


build: clean deps
@# Install OpenFisca-Extension-Template for deployment and publishing.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# We can run this test on our command line using `openfisca-run-test tests/situations/income_tax.yaml`

- name: Parenting allowance for a two parent household with little income
description: Parenting allowance relies on the incomes on the parents and ages of the children
period: 2020-01
description: Parenting allowance relies on the fortnight incomes of the parents and ages of the children
period: 2022
absolute_error_margin: 0
input:
household:
Expand All @@ -12,14 +12,14 @@
persons:
Phil:
birth: 1981-01-15
salary:
2017-01: 250
2018-01: 250
weekly_salary:
week:2022-W01:2: 250
week:2022-W03:2: 250
Saz:
birth: 1982-01-15
salary:
2017-01: 250
2018-01: 251
weekly_salary:
week:2022-W01:2: 250
week:2022-W03:2: 251
Caz:
birth: 2010-01-15
Eille:
Expand All @@ -29,5 +29,5 @@
output:
household:
parenting_allowance:
2017-01: 600
2018-01: 0
2022-W03: 600
2022-W05: 0
23 changes: 17 additions & 6 deletions openfisca_country_template/variables/benefits.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"""

# Import from openfisca-core the Python objects used to code the legislation in OpenFisca
from openfisca_core.periods import MONTH
from openfisca_core.periods import MONTH, WEEK
from openfisca_core.variables import Variable

# Import the Entities specifically defined for this tax and benefit system
Expand Down Expand Up @@ -91,14 +91,13 @@ def formula(person, period, parameters):
class parenting_allowance(Variable):
value_type = float
entity = Household
definition_period = MONTH
definition_period = WEEK
label = "Allowance for low income people with children to care for."
documentation = "Loosely based on the Australian parenting pension."
reference = "https://www.servicesaustralia.gov.au/individuals/services/centrelink/parenting-payment/who-can-get-it"

def formula(household, period, parameters):
"""
Parenting allowance for households.
"""Parenting allowance for households.

A person's parenting allowance depends on how many dependents they have,
how much they, and their partner, earn
Expand All @@ -107,12 +106,12 @@ def formula(household, period, parameters):
"""
parenting_allowance = parameters(period).benefits.parenting_allowance

household_income = household("household_income", period)
household_income = household("household_weekly_income", period.last_2_weeks, options = ["add"])
income_threshold = parenting_allowance.income_threshold
income_condition = household_income <= income_threshold

is_single = household.nb_persons(Household.PARENT) == 1
ages = household.members("age", period)
ages = household.members("age", period.first_month)
under_8 = household.any(ages < 8)
under_6 = household.any(ages < 6)

Expand All @@ -132,3 +131,15 @@ def formula(household, period, _parameters):
"""A household's income."""
salaries = household.members("salary", period)
return household.sum(salaries)


class household_weekly_income(Variable):
value_type = float
entity = Household
definition_period = WEEK
label = "The sum of the salaries of those living in a household"

def formula(household, period, _parameters):
"""A household's income."""
salaries = household.members("weekly_salary", period)
return household.sum(salaries)
12 changes: 11 additions & 1 deletion openfisca_country_template/variables/income.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

# Import from openfisca-core the Python objects used to code the legislation in OpenFisca
from openfisca_core.holders import set_input_divide_by_period
from openfisca_core.periods import MONTH
from openfisca_core.periods import MONTH, WEEK
from openfisca_core.variables import Variable

# Import the Entities specifically defined for this tax and benefit system
Expand All @@ -25,6 +25,16 @@ class salary(Variable):
reference = "https://law.gov.example/salary" # Always use the most official source


# This variable is also a pure input, but with a different definition period
class weekly_salary(Variable):
value_type = float
entity = Person
definition_period = WEEK
set_input = set_input_divide_by_period # Optional attribute. Allows user to declare a salary for a week. OpenFisca will then multiply the weekly amount over the weeks requested.
label = "Weekly Salary"
reference = "https://law.another-gov.example/salary" # Always use the most official source (and https)


class disposable_income(Variable):
value_type = float
entity = Person
Expand Down