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

Add parameter and variable with non ascii character #29

Merged
merged 4 commits into from
Feb 5, 2018
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
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Changelog

## 2.1.0

* Tax and benefit system evolution
* Impacted areas:
- Parameters `general`
- Variables `benefits`
* Details:
- Add a parameter and a variable with non ascii characters
- Introduce `age_of_retirement` parameter
- Introduce `pension` variable

## 2.0.1 - [#24](https://github.com/openfisca/country-template/pull/24) [#27](https://github.com/openfisca/country-template/pull/27)

_Note: the 2.0.0 version has been unpublished due to performance issues_
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# A parameter can contain utf-8 characters.
description: Age of retirement (in years). Âge de la retraite (en années).
reference: https://fr.wikipedia.org/wiki/Retraite_(économie)
values:
2017-01-01:
value: 62.0
1951-07-01:
value: 60.33
17 changes: 17 additions & 0 deletions openfisca_country_template/variables/benefits.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,20 @@ class housing_allowance(Variable):
# 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, parameters):
return household('rent', period) * parameters(period).benefits.housing_allowance


# By default, you can use utf-8 characters in a variable. OpenFisca web API manages utf-8 encoding.
class pension(Variable):
value_type = float
entity = Person
definition_period = MONTH
label = "Pension for the elderly. Pension attribuée aux personnes âgées."
reference = [u"https://fr.wikipedia.org/wiki/Retraite_(économie)", u"https://ar.wikipedia.org/wiki/تقاعد"]

def formula(person, period):
'''
A person's pension depends on its birth date.
In french : La pension d'une personne est attribuée d'après la date de naissance.
'''
age_condition = person('age', period) >= parameters(period).general.age_of_retirement
return age_condition
2 changes: 1 addition & 1 deletion openfisca_country_template/variables/demographics.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ class birth(Variable):
entity = Person
label = u"Birth date"
definition_period = ETERNITY # This variable cannot change over time.
reference = "https://en.wiktionary.org/wiki/birthdate"
reference = u"https://en.wiktionary.org/wiki/birthdate"
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

setup(
name='OpenFisca-Country-Template',
version='2.0.1',
version='2.1.0rc0',
author='OpenFisca Team',
author_email='contact@openfisca.fr',
description=u'OpenFisca tax and benefit system for Country-Template',
Expand Down