Skip to content

Commit

Permalink
Add parameter and variable with non ascii character
Browse files Browse the repository at this point in the history
Merge pull request #29 from openfisca/decode-variable-891
  • Loading branch information
sandcha authored Feb 5, 2018
2 parents 73ce94c + 6306138 commit 854e5fb
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 2 deletions.
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

0 comments on commit 854e5fb

Please sign in to comment.