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

Upgrade OpenFisca-Core to v14 #10

Merged
merged 4 commits into from
Jun 12, 2017
Merged
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
23 changes: 18 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
# 1.1.0 - [#7](https://github.com/openfisca/country-template/pull/7)
# Changelog

* Tax and benefit system evolution: add a reform modifying the brackets of a scale
## 1.2.0 - [#10](https://github.com/openfisca/country-template/pull/10)

* Technical improvement
* Details:
- Upgrade OpenFisca-Core
- Update the way we define formulas start dates and variables stop dates.
- Update the naming conventions for variable formulas.
- See the [OpenFisca-Core Changelog](https://github.com/openfisca/openfisca-core/blob/master/CHANGELOG.md#1400---522).

## 1.1.0 - [#7](https://github.com/openfisca/country-template/pull/7)

* Tax and benefit system evolution
* Impacted periods: from 2013-01-01
* Impacted areas: `openfisca_country_template/parameters/taxes.xml`
* Impacted areas:
- Reform: `modify_social_security_taxation`
* Details:
- Show how to add, modify and remove a bracket.
- Add corresponding tests.
- Add a reform modifying the brackets of a scale
- Show how to add, modify and remove a bracket.
- Add corresponding tests.

# 1.0.0 - [#4](https://github.com/openfisca/country-template/pull/4)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
class social_security_contribution(Variable):
# Variable metadata don't need to be redefined. By default, the reference variable metadatas will be used.

def function(person, period, legislation):
def formula(person, period, legislation):
return person('salary', period) * 0.03


Expand Down
14 changes: 6 additions & 8 deletions openfisca_country_template/variables/benefits.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,21 @@
from openfisca_country_template.entities import *


class basic_income(DatedVariable):
class basic_income(Variable):
column = FloatCol
entity = Person
definition_period = MONTH
label = "Basic income provided to adults"
url = "https://law.gov.example/basic_income" # Always use the most official source

# Since Dec 1st 2016, the basic income is provided to any adult, without considering their income.
@dated_function(start = date(2016, 12, 1))
def function_from_2016_12(person, period, legislation):
def formula_2016_12(person, period, legislation):
age_condition = person('age', period) >= legislation(period).general.age_of_majority
return age_condition * legislation(period).benefits.basic_income # This '*' is a vectorial 'if'. See https://doc.openfisca.fr/coding-the-legislation/30_case_disjunction.html#simple-multiplication

# From Dec 1st 2015 to Nov 30 2016, the basic income is provided to adults who have no income.
# Before Dec 1st 2015, the basic income does not exist in the law, and calculating it returns its default value, which is 0.
@dated_function(start = date(2015, 12, 1), stop = date(2016, 11, 30))
def function_until_2016_12(person, period, legislation):
def formula_2015_12(person, period, legislation):
age_condition = person('age', period) >= legislation(period).general.age_of_majority
salary_condition = person('salary', period) == 0
return age_condition * salary_condition * legislation(period).benefits.basic_income # The '*' is also used as a vectorial 'and'. See https://doc.openfisca.fr/coding-the-legislation/25_vectorial_computing.html#forbidden-operations-and-alternatives
Expand All @@ -38,8 +36,8 @@ class housing_allowance(Variable):
definition_period = MONTH
label = "Housing allowange"
url = "https://law.gov.example/housing_allowance" # Always use the most official source
start_date = date(1980, 1, 1) # This allowance was introduced on the 1st of Jan 1980. Calculating it before this date will always return the variable default value, 0.
stop_date = date(2016, 11, 30) # This allowance was removed on the 1st of Dec 2016. Calculating it before this date will always return the variable default value, 0.
end = '2016-11-30' # This allowance was removed on the 1st of Dec 2016. Calculating it before this date will always return the variable default value, 0.

def function(household, period, legislation):
# This allowance was introduced on the 1st of Jan 1980. Calculating it before this date will always return the variable default value, 0.
def formula_1980(household, period, legislation):
return household('rent', period) * legislation(period).benefits.housing_allowance
2 changes: 1 addition & 1 deletion openfisca_country_template/variables/demographics.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class age(Variable):
label = u"Person's age (in years)"

# A person's age is computed according to its birth date.
def function(person, period, legislation):
def formula(person, period, legislation):
birth = person('birth', period)
return (datetime64(period.date) - birth).astype('timedelta64[Y]')

Expand Down
2 changes: 1 addition & 1 deletion openfisca_country_template/variables/income.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class disposable_income(Variable):
label = "Actual amount available to the person at the end of the month"
url = "https://stats.gov.example/disposable_income" # Some variables represent quantities used in economic models, and not defined by law. Always give the source of your definition.

def function(person, period, legislation):
def formula(person, period, legislation):
return (
+ person('salary', period)
+ person('basic_income', period)
Expand Down
6 changes: 3 additions & 3 deletions openfisca_country_template/variables/taxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class income_tax(Variable):
url = "https://law.gov.example/income_tax" # Always use the most official source

# The formula to compute the income tax for a given person at a given period
def function(person, period, legislation):
def formula(person, period, legislation):
return person('salary', period) * legislation(period).taxes.income_tax_rate


Expand All @@ -29,7 +29,7 @@ class social_security_contribution(Variable):
label = u"Progressive contribution paid on salaries to finance social security"
url = "https://law.gov.example/social_security_contribution" # Always use the most official source

def function(person, period, legislation):
def formula(person, period, legislation):
salary = person('salary', period)

# The social_security_contribution is computed according to a marginal scale.
Expand All @@ -45,7 +45,7 @@ class housing_tax(Variable):
label = u"Tax paid by each household proportionnally to the size of its accommodation"
url = "https://law.gov.example/housing_tax" # Always use the most official source

def function(household, period, legislation):
def formula(household, period, legislation):
# The housing tax is defined for a year, but depends on the `accomodation_size` on the first month of the year.
# Here period is a year. We can get the first month of a year with the following shortcut.
# To build different periods, see https://doc.openfisca.fr/coding-the-legislation/35_periods.html#calculating-dependencies-for-a-specific-period
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

setup(
name='OpenFisca-Country-Template',
version='1.1.0',
version='1.2.0',
author='OpenFisca Team',
author_email='contact@openfisca.fr',
description=u'OpenFisca tax and benefit system for Country-Template',
Expand All @@ -16,7 +16,7 @@
url='https://github.com/openfisca/openfisca-country-template',
include_package_data = True, # Will read MANIFEST.in
install_requires=[
'OpenFisca-Core >= 12.0.0, < 13.0',
'OpenFisca-Core >= 14.0.0, < 15.0',
],
extras_require = {
'api': [
Expand Down