From b5a55eac348e0dc885fc44027c02cb72dd86b98d Mon Sep 17 00:00:00 2001 From: sandcha Date: Fri, 2 Feb 2018 11:14:38 +0100 Subject: [PATCH 1/4] Add non ascii characters to demographics variables --- openfisca_country_template/variables/demographics.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/openfisca_country_template/variables/demographics.py b/openfisca_country_template/variables/demographics.py index 6395928f..f92b5132 100644 --- a/openfisca_country_template/variables/demographics.py +++ b/openfisca_country_template/variables/demographics.py @@ -13,13 +13,18 @@ class age(Variable): + # By default, you can use utf-8 characters in a variable. OpenFisca web API manages utf-8 encoding. value_type = int entity = Person definition_period = MONTH - label = u"Person's age (in years)" + label = u"Person's age (in years). In french : Âge d'une personne (en années)." + reference = u"https://ar.wikipedia.org/wiki/العمر" - # A person's age is computed according to its birth date. def formula(person, period, parameters): + ''' + A person's age is computed according to its birth date. + In french : L'âge d'une personne est calculé d'après sa date de naissance. + ''' birth = person('birth', period) return (datetime64(period.date) - birth).astype('timedelta64[Y]') @@ -31,4 +36,3 @@ 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" From 90dbe5d1c4deeb969ddca78a3dd07d53c3c26702 Mon Sep 17 00:00:00 2001 From: sandcha Date: Fri, 2 Feb 2018 11:49:35 +0100 Subject: [PATCH 2/4] Add pension variable with utf-8 characters --- .../parameters/general/age_of_retirement.yaml | 6 ++++++ .../variables/benefits.py | 17 +++++++++++++++++ .../variables/demographics.py | 10 +++------- 3 files changed, 26 insertions(+), 7 deletions(-) create mode 100644 openfisca_country_template/parameters/general/age_of_retirement.yaml diff --git a/openfisca_country_template/parameters/general/age_of_retirement.yaml b/openfisca_country_template/parameters/general/age_of_retirement.yaml new file mode 100644 index 00000000..c115a7da --- /dev/null +++ b/openfisca_country_template/parameters/general/age_of_retirement.yaml @@ -0,0 +1,6 @@ +description: Age of retirement (in years) +values: + 2017-01-01: + value: 62.0 + 1951-07-01: + value: 60.33 diff --git a/openfisca_country_template/variables/benefits.py b/openfisca_country_template/variables/benefits.py index 2f7d7c86..80e44fef 100644 --- a/openfisca_country_template/variables/benefits.py +++ b/openfisca_country_template/variables/benefits.py @@ -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 diff --git a/openfisca_country_template/variables/demographics.py b/openfisca_country_template/variables/demographics.py index f92b5132..30e4b82d 100644 --- a/openfisca_country_template/variables/demographics.py +++ b/openfisca_country_template/variables/demographics.py @@ -13,18 +13,13 @@ class age(Variable): - # By default, you can use utf-8 characters in a variable. OpenFisca web API manages utf-8 encoding. value_type = int entity = Person definition_period = MONTH - label = u"Person's age (in years). In french : Âge d'une personne (en années)." - reference = u"https://ar.wikipedia.org/wiki/العمر" + label = u"Person's age (in years)" + # A person's age is computed according to its birth date. def formula(person, period, parameters): - ''' - A person's age is computed according to its birth date. - In french : L'âge d'une personne est calculé d'après sa date de naissance. - ''' birth = person('birth', period) return (datetime64(period.date) - birth).astype('timedelta64[Y]') @@ -36,3 +31,4 @@ class birth(Variable): entity = Person label = u"Birth date" definition_period = ETERNITY # This variable cannot change over time. + reference = u"https://en.wiktionary.org/wiki/birthdate" From f17d1742f59416f5bbb648964bb37f352b938b30 Mon Sep 17 00:00:00 2001 From: sandcha Date: Fri, 2 Feb 2018 12:38:52 +0100 Subject: [PATCH 3/4] Add utf-8 characters (non ascii) in age_of_retirement parameter --- .../parameters/general/age_of_retirement.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/openfisca_country_template/parameters/general/age_of_retirement.yaml b/openfisca_country_template/parameters/general/age_of_retirement.yaml index c115a7da..0c00a9ef 100644 --- a/openfisca_country_template/parameters/general/age_of_retirement.yaml +++ b/openfisca_country_template/parameters/general/age_of_retirement.yaml @@ -1,4 +1,6 @@ -description: Age of retirement (in years) +# 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 From 63061386f8ea2c152b29a87a984e3ae183c9f7f8 Mon Sep 17 00:00:00 2001 From: sandcha Date: Fri, 2 Feb 2018 13:17:53 +0100 Subject: [PATCH 4/4] Bump version --- CHANGELOG.md | 11 +++++++++++ setup.py | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 995ca6ed..980d0e42 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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_ diff --git a/setup.py b/setup.py index e15741ce..a4177c16 100755 --- a/setup.py +++ b/setup.py @@ -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',