From e828bcc4e4205eb55962b7f97627c2028f9c9e37 Mon Sep 17 00:00:00 2001 From: TOMAS Frederic Date: Wed, 3 Jun 2020 15:45:38 +0200 Subject: [PATCH 1/6] =?UTF-8?q?Ajoute=20les=20parametres=20n=C3=A9cessaire?= =?UTF-8?q?s=20=C3=A0=20l'aide=20AdeFIP=20Eure=20et=20Loire?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../departements/eure_loire/adefip.py | 0 .../parameters/departements/eure_loire | 39 +++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 openfisca_france_local/departements/eure_loire/adefip.py create mode 100644 openfisca_france_local/parameters/departements/eure_loire diff --git a/openfisca_france_local/departements/eure_loire/adefip.py b/openfisca_france_local/departements/eure_loire/adefip.py new file mode 100644 index 00000000..e69de29b diff --git a/openfisca_france_local/parameters/departements/eure_loire b/openfisca_france_local/parameters/departements/eure_loire new file mode 100644 index 00000000..7b628426 --- /dev/null +++ b/openfisca_france_local/parameters/departements/eure_loire @@ -0,0 +1,39 @@ +adefip: + montants: + montant_formation_3_mois_ou_plus: + values: + 2020-01-01: + value: 500 + montant_cdd_3_a_6_mois: + values: + 2020-01-01: + value: 400 + montant_cdd_6_mois_ou_plus: + values: + 2020-01-01: + value: 500 + montant_cdi_temps_plein: + values: + 2020-01-01: + value: 600 + montant_cdi_temps_partiel: + values: + 2020-01-01: + value: 300 + montant_creation_reprise_entreprise: + values: + 2020-01-01: + value: 700 + durees: + duree_minimum_formation: + values: + 2020-01-01: + value: 3 + duree_minimum_cdd_palier1: + values: + 2020-01-01: + value: 3 + duree_minimum_cdd_palier2: + values: + 2020-01-01: + value: 6 \ No newline at end of file From accd2e189704ed2aa956af014b13f77e9680dbda Mon Sep 17 00:00:00 2001 From: TOMAS Frederic Date: Wed, 3 Jun 2020 15:46:11 +0200 Subject: [PATCH 2/6] Ajoute l'aide AdeFIP Eure et Loire --- .../departements/eure_loire/FAJ.py | 18 +++ .../departements/eure_loire/adefip.py | 145 ++++++++++++++++++ .../eure_loire/transportsocial.py | 30 ++++ .../{eure_loire => eure_loire.yml} | 0 .../FAJ_transportsocial_pretvehicule.yml | 25 +++ 5 files changed, 218 insertions(+) create mode 100644 openfisca_france_local/departements/eure_loire/FAJ.py create mode 100644 openfisca_france_local/departements/eure_loire/transportsocial.py rename openfisca_france_local/parameters/departements/{eure_loire => eure_loire.yml} (100%) create mode 100644 tests/departements/eure_et_loir/FAJ_transportsocial_pretvehicule.yml diff --git a/openfisca_france_local/departements/eure_loire/FAJ.py b/openfisca_france_local/departements/eure_loire/FAJ.py new file mode 100644 index 00000000..f196d58a --- /dev/null +++ b/openfisca_france_local/departements/eure_loire/FAJ.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- +from openfisca_france.model.base import Variable, Individu, MONTH + + +class eure_et_loir_eligibilite_FAJ(Variable): + value_type = bool + entity = Individu + definition_period = MONTH + label = "Éligibilité au Fond d'Aide aux Jeunes" + + def formula(individu, period, parameters): + reside_eure_et_loir = individu.menage('eure_loire_eligibilite_residence', period) + age = individu('age', period) + a_entre_18_25_ans = (age >= 18) * (age <= 25) + rsa = parameters(period).prestations.minima_sociaux.rsa + revenue_inferieur_RSA = individu('eure_et_loir_revenus_nets_du_travail', period) < rsa.montant_de_base_du_rsa + + return reside_eure_et_loir * a_entre_18_25_ans * revenue_inferieur_RSA diff --git a/openfisca_france_local/departements/eure_loire/adefip.py b/openfisca_france_local/departements/eure_loire/adefip.py index e69de29b..2677213e 100644 --- a/openfisca_france_local/departements/eure_loire/adefip.py +++ b/openfisca_france_local/departements/eure_loire/adefip.py @@ -0,0 +1,145 @@ +# -*- coding: utf-8 -*- +from openfisca_core import parameters +from openfisca_france.model.base import * # noqa analysis:ignore + +from numpy.core.defchararray import startswith + + +class eure_loire_eligibilite_residence(Variable): + value_type = bool + entity = Menage + definition_period = MONTH + label = u"Éligibilité résidentielle d'un ménage aux dipositifs de l'Eure et Loire" + + def formula(menage, period): + return startswith(menage('depcom', period), b'28') + + +class adefip_eligibilite_activite(Variable): + value_type = bool + entity = Individu + definition_period = MONTH + label = u"Éligibilité en lien avec l'activité de l'individu" + + def formula(individu, period, parameters): + params_adefip = parameters(period).departements.eure_loire.adefip + duree_activite = individu('duree_contrat_ou_formation', period) + + contrat_de_travail_duree = individu('contrat_de_travail_duree', period) + TypesContratDeTravailDuree = contrat_de_travail_duree.possible_values + + # cas formation + formation = individu('formation', period) + condition_formation = formation * (duree_activite >= params_adefip.durees.duree_minimum_formation) + + # cas CDD + condition_duree_cdd = duree_activite >= params_adefip.durees.duree_minimum_cdd_palier1 + condition_cdd = not_(condition_formation) * (contrat_de_travail_duree == TypesContratDeTravailDuree.cdd) * condition_duree_cdd + + # cas CDI + condition_cdi = not_(condition_formation) * (contrat_de_travail_duree == TypesContratDeTravailDuree.cdi) + + return condition_formation + condition_cdd + condition_cdi + + +class adefip_eligibilite(Variable): + value_type = bool + entity = Individu + definition_period = MONTH + + def formula(individu, period): + annee_glissante = period.start.period('year').offset(-1) + + # conditions de domiciliation + residence_eure_loire = individu.menage('eure_loire_eligibilite_residence', period) + + # conditions de RSA + percoit_rsa = individu.famille('rsa', period) + + # conditions de AdéFIP + adefip_12_derniers_mois = individu('adefip', annee_glissante, options=[ADD]) + ne_percoit_pas_adefip_12_derniers_mois = (adefip_12_derniers_mois == 0) + + # conditions de CER et PPAE + avoir_cer_ppae = individu('cer_ou_ppae', period) + + # conditions d'emplois/entreprise + condition_activite = individu('adefip_eligibilite_activite', period); + condition_entreprise = not_(condition_activite) * individu('creation_ou_reprise_entreprise', period) + + return residence_eure_loire * percoit_rsa * ne_percoit_pas_adefip_12_derniers_mois * avoir_cer_ppae * (condition_activite + condition_entreprise) + + +class adefip_montant(Variable): + value_type = float + entity = Individu + definition_period = MONTH + + def formula(individu, period, parameters): + params_adefip = parameters(period).departements.eure_loire.adefip + + duree_activite = individu('duree_contrat_ou_formation', period) + + contrat_de_travail = individu('contrat_de_travail', period) + TypesContratDeTravail = contrat_de_travail.possible_values + + contrat_de_travail_duree = individu('contrat_de_travail_duree', period) + TypesContratDeTravailDuree = contrat_de_travail_duree.possible_values + + # cas formation + formation = individu('formation', period) + condition_formation = formation * ( + duree_activite >= params_adefip.durees.duree_minimum_formation) + montant_formation = condition_formation * params_adefip.montants.montant_formation_3_mois_ou_plus + + # cas creation ou reprise entreprise + condition_entreprise = not_(condition_formation) * individu('creation_ou_reprise_entreprise', period) + montant_creation_reprise_entreprise = condition_entreprise * params_adefip.montants.montant_creation_reprise_entreprise + + # cas CDD palier 1 (entre 3 et 6 mois) + est_en_cdd = contrat_de_travail_duree == TypesContratDeTravailDuree.cdd + condition_duree_cdd_palier_1_min = (duree_activite >= params_adefip.durees.duree_minimum_cdd_palier1) + condition_duree_cdd_palier_1_max = (duree_activite <= params_adefip.durees.duree_minimum_cdd_palier2) + condition_cdd_palier_1 = est_en_cdd * condition_duree_cdd_palier_1_min * condition_duree_cdd_palier_1_max + montant_cdd_palier_1 = condition_cdd_palier_1 * params_adefip.montants.montant_cdd_3_a_6_mois + + # cas CDD palier 2 (plus de 6 mois) + condition_duree_cdd_palier_2_min = (duree_activite > params_adefip.durees.duree_minimum_cdd_palier2) + condition_cdd_palier_2 = est_en_cdd * condition_duree_cdd_palier_2_min + montant_cdd_palier_2 = condition_cdd_palier_2 * params_adefip.montants.montant_cdd_6_mois_ou_plus + + montant_cdd = (montant_cdd_palier_1 + montant_cdd_palier_2) * not_(condition_formation) * not_(condition_entreprise) + + # cas CDI temps plein + est_en_cdi = contrat_de_travail_duree == TypesContratDeTravailDuree.cdi + est_a_temps_plein = contrat_de_travail == TypesContratDeTravail.temps_plein + condition_cdi_temps_plein = est_en_cdi * est_a_temps_plein + montant_cdi_temps_plein = condition_cdi_temps_plein * params_adefip.montants.montant_cdi_temps_plein + + # cas CDI temps partiel + est_a_temps_partiel = contrat_de_travail == TypesContratDeTravail.temps_partiel + condition_cdi_temps_partiel = est_en_cdi * est_a_temps_partiel + montant_cdi_temps_partiel = condition_cdi_temps_partiel * params_adefip.montants.montant_cdi_temps_partiel + + montant_cdi = (montant_cdi_temps_plein + montant_cdi_temps_partiel) * not_(condition_formation) * not_(condition_entreprise) + + montant_adefip = montant_formation + montant_cdd + montant_cdi + montant_creation_reprise_entreprise + + return montant_adefip + + +class adefip(Variable): + value_type = int + entity = Individu + definition_period = MONTH + set_input = set_input_divide_by_period + + def formula(individu, period): + + # eligibilite + eligibilite = individu('adefip_eligibilite', period) + + # montant + montant = individu('adefip_montant', period) + + return montant * eligibilite \ No newline at end of file diff --git a/openfisca_france_local/departements/eure_loire/transportsocial.py b/openfisca_france_local/departements/eure_loire/transportsocial.py new file mode 100644 index 00000000..1032a0dd --- /dev/null +++ b/openfisca_france_local/departements/eure_loire/transportsocial.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +from openfisca_france.model.base import Variable, Individu, MONTH + + +class eure_et_loir_revenus_nets_du_travail(Variable): + value_type = float + entity = Individu + definition_period = MONTH + label = "Montant des revenus nets du travail" + + def formula(individu, period): + # Il faudra ajouter des revenus ici + return individu('salaire_net', period) + + +class eure_et_loir_eligibilite_transportsocial(Variable): + value_type = bool + entity = Individu + definition_period = MONTH + label = "Transport social" + + def formula(individu, period, parameters): + reside_eure_et_loir = individu.menage('eure_loire_eligibilite_residence', period) + recoit_rsa = individu.famille('rsa', period) > 0 + age = individu('age', period) + a_entre_18_25_ans = (age >= 18) * (age <= 25) + rsa = parameters(period).prestations.minima_sociaux.rsa + revenue_inferieur_RSA = individu('eure_et_loir_revenus_nets_du_travail', period) < rsa.montant_de_base_du_rsa + + return reside_eure_et_loir * (recoit_rsa + a_entre_18_25_ans * revenue_inferieur_RSA) diff --git a/openfisca_france_local/parameters/departements/eure_loire b/openfisca_france_local/parameters/departements/eure_loire.yml similarity index 100% rename from openfisca_france_local/parameters/departements/eure_loire rename to openfisca_france_local/parameters/departements/eure_loire.yml diff --git a/tests/departements/eure_et_loir/FAJ_transportsocial_pretvehicule.yml b/tests/departements/eure_et_loir/FAJ_transportsocial_pretvehicule.yml new file mode 100644 index 00000000..76c59438 --- /dev/null +++ b/tests/departements/eure_et_loir/FAJ_transportsocial_pretvehicule.yml @@ -0,0 +1,25 @@ +- period: 2020-10 + input: + depcom: [28000, 28000, 28000, 28000, 28000] + age: [22, 23, 18, 25, 5] + salaire_net: [500, 900, 400, 1200, 500] + rsa: [0, 100, 0, 300, 0] + output: + eure_et_loir_eligibilite_transportsocial: [true, true, true, true, false ] + + +- period: 2020-10 + input: + depcom: [28000, 28000, 28000, 28000] + age: [22, 18, 25, 5] + salaire_net: [500, 400, 1200, 200] + output: + eure_et_loir_eligibilite_FAJ: [true, true, false, false ] + + +- period: 2020-10 + input: + depcom: [28000, 31300, 28000] + rsa: [150, 100, 0] + output: + eure_et_loir_eligibilite_transportsocial: [true, false, false] From 6ba5735ab84a74e770763a1cd665acad53478beb Mon Sep 17 00:00:00 2001 From: TOMAS Frederic Date: Tue, 25 May 2021 17:13:18 +0200 Subject: [PATCH 3/6] Corrige une erreur de rebase et reorganise les fichiers --- .../departements/eure_et_loir/adefip.py | 146 ++++++++++++- .../departements/eure_loire/FAJ.py | 18 -- .../departements/eure_loire/adefip.py | 145 ------------- .../eure_loire/transportsocial.py | 30 --- .../departements/eure_et_loir/adefip.yml | 38 ++++ .../parameters/departements/eure_loire.yml | 39 ---- .../FAJ_transportsocial_pretvehicule.yml | 6 +- tests/departements/eure_et_loir/adefip.yml | 205 +++++++----------- 8 files changed, 262 insertions(+), 365 deletions(-) delete mode 100644 openfisca_france_local/departements/eure_loire/FAJ.py delete mode 100644 openfisca_france_local/departements/eure_loire/adefip.py delete mode 100644 openfisca_france_local/departements/eure_loire/transportsocial.py create mode 100644 openfisca_france_local/parameters/departements/eure_et_loir/adefip.yml delete mode 100644 openfisca_france_local/parameters/departements/eure_loire.yml diff --git a/openfisca_france_local/departements/eure_et_loir/adefip.py b/openfisca_france_local/departements/eure_et_loir/adefip.py index c9a83f9c..20e956c5 100644 --- a/openfisca_france_local/departements/eure_et_loir/adefip.py +++ b/openfisca_france_local/departements/eure_et_loir/adefip.py @@ -1,7 +1,8 @@ # -*- coding: utf-8 -*- -from numpy import logical_not as not_ +from openfisca_france.model.base import * -from openfisca_france.model.base import Variable, Individu, MONTH +from numpy import logical_not as not_ +from numpy.core.defchararray import startswith class eure_et_loir_adefip_versee(Variable): value_type = bool @@ -10,15 +11,144 @@ class eure_et_loir_adefip_versee(Variable): label = u"AdéFIP versée en une fois dans les 12 derniers mois" -class eure_et_loir_eligibilite_adefip(Variable): +class eure_loire_eligibilite_residence(Variable): + value_type = bool + entity = Menage + definition_period = MONTH + label = u"Éligibilité résidentielle d'un ménage aux dipositifs de l'Eure et Loire" + + def formula(menage, period): + return startswith(menage('depcom', period), b'28') + + +class adefip_eligibilite_activite(Variable): + value_type = bool + entity = Individu + definition_period = MONTH + label = u"Éligibilité en lien avec l'activité de l'individu" + + def formula(individu, period, parameters): + params_adefip = parameters(period).departements.eure_et_loir.adefip + duree_activite = individu('duree_contrat_ou_formation', period) + + contrat_de_travail_duree = individu('contrat_de_travail_duree', period) + TypesContratDeTravailDuree = contrat_de_travail_duree.possible_values + + # cas formation + formation = individu('formation', period) + condition_formation = formation * (duree_activite >= params_adefip.durees.duree_minimum_formation) + + # cas CDD + condition_duree_cdd = duree_activite >= params_adefip.durees.duree_minimum_cdd_palier1 + condition_cdd = not_(condition_formation) * ( + contrat_de_travail_duree == TypesContratDeTravailDuree.cdd) * condition_duree_cdd + + # cas CDI + condition_cdi = not_(condition_formation) * (contrat_de_travail_duree == TypesContratDeTravailDuree.cdi) + + return condition_formation + condition_cdd + condition_cdi + + +class adefip_eligibilite(Variable): value_type = bool entity = Individu definition_period = MONTH - label = u"Éligibilité à l'AdéFIP" def formula(individu, period): - recoit_rsa = individu.famille('rsa', period) > 0 - reside_eure_et_loir = individu.menage('eure_et_loir_eligibilite_residence', period) - eure_et_loir_adefip_versee = individu('eure_et_loir_adefip_versee', period) + annee_glissante = period.start.period('year').offset(-1) + + # conditions de domiciliation + residence_eure_loire = individu.menage('eure_loire_eligibilite_residence', period) + + # conditions de RSA + percoit_rsa = individu.famille('rsa', period) + + # conditions de AdéFIP + adefip_12_derniers_mois = individu('adefip', annee_glissante, options=[ADD]) + ne_percoit_pas_adefip_12_derniers_mois = (adefip_12_derniers_mois == 0) + + # conditions de CER et PPAE + avoir_cer_ppae = individu('cer_ou_ppae', period) + + # conditions d'emplois/entreprise + condition_activite = individu('adefip_eligibilite_activite', period); + condition_entreprise = not_(condition_activite) * individu('creation_ou_reprise_entreprise', period) + + return residence_eure_loire * percoit_rsa * ne_percoit_pas_adefip_12_derniers_mois * avoir_cer_ppae * ( + condition_activite + condition_entreprise) + + +class adefip_montant(Variable): + value_type = float + entity = Individu + definition_period = MONTH + + def formula(individu, period, parameters): + params_adefip = parameters(period).departements.eure_et_loir.adefip + + duree_activite = individu('duree_contrat_ou_formation', period) + + contrat_de_travail = individu('contrat_de_travail', period) + TypesContratDeTravail = contrat_de_travail.possible_values + + contrat_de_travail_duree = individu('contrat_de_travail_duree', period) + TypesContratDeTravailDuree = contrat_de_travail_duree.possible_values + + # cas formation + formation = individu('formation', period) + condition_formation = formation * ( + duree_activite >= params_adefip.durees.duree_minimum_formation) + montant_formation = condition_formation * params_adefip.montants.montant_formation_3_mois_ou_plus + + # cas creation ou reprise entreprise + condition_entreprise = not_(condition_formation) * individu('creation_ou_reprise_entreprise', period) + montant_creation_reprise_entreprise = condition_entreprise * params_adefip.montants.montant_creation_reprise_entreprise + + # cas CDD palier 1 (entre 3 et 6 mois) + est_en_cdd = contrat_de_travail_duree == TypesContratDeTravailDuree.cdd + condition_duree_cdd_palier_1_min = (duree_activite >= params_adefip.durees.duree_minimum_cdd_palier1) + condition_duree_cdd_palier_1_max = (duree_activite <= params_adefip.durees.duree_minimum_cdd_palier2) + condition_cdd_palier_1 = est_en_cdd * condition_duree_cdd_palier_1_min * condition_duree_cdd_palier_1_max + montant_cdd_palier_1 = condition_cdd_palier_1 * params_adefip.montants.montant_cdd_3_a_6_mois + + # cas CDD palier 2 (plus de 6 mois) + condition_duree_cdd_palier_2_min = (duree_activite > params_adefip.durees.duree_minimum_cdd_palier2) + condition_cdd_palier_2 = est_en_cdd * condition_duree_cdd_palier_2_min + montant_cdd_palier_2 = condition_cdd_palier_2 * params_adefip.montants.montant_cdd_6_mois_ou_plus + + montant_cdd = (montant_cdd_palier_1 + montant_cdd_palier_2) * not_(condition_formation) * not_( + condition_entreprise) + + # cas CDI temps plein + est_en_cdi = contrat_de_travail_duree == TypesContratDeTravailDuree.cdi + est_a_temps_plein = contrat_de_travail == TypesContratDeTravail.temps_plein + condition_cdi_temps_plein = est_en_cdi * est_a_temps_plein + montant_cdi_temps_plein = condition_cdi_temps_plein * params_adefip.montants.montant_cdi_temps_plein + + # cas CDI temps partiel + est_a_temps_partiel = contrat_de_travail == TypesContratDeTravail.temps_partiel + condition_cdi_temps_partiel = est_en_cdi * est_a_temps_partiel + montant_cdi_temps_partiel = condition_cdi_temps_partiel * params_adefip.montants.montant_cdi_temps_partiel + + montant_cdi = (montant_cdi_temps_plein + montant_cdi_temps_partiel) * not_(condition_formation) * not_( + condition_entreprise) + + montant_adefip = montant_formation + montant_cdd + montant_cdi + montant_creation_reprise_entreprise + + return montant_adefip + + +class adefip(Variable): + value_type = int + entity = Individu + definition_period = MONTH + set_input = set_input_divide_by_period + + def formula(individu, period): + # eligibilite + eligibilite = individu('adefip_eligibilite', period) + + # montant + montant = individu('adefip_montant', period) - return not_(eure_et_loir_adefip_versee) * recoit_rsa * reside_eure_et_loir + return montant * eligibilite diff --git a/openfisca_france_local/departements/eure_loire/FAJ.py b/openfisca_france_local/departements/eure_loire/FAJ.py deleted file mode 100644 index f196d58a..00000000 --- a/openfisca_france_local/departements/eure_loire/FAJ.py +++ /dev/null @@ -1,18 +0,0 @@ -# -*- coding: utf-8 -*- -from openfisca_france.model.base import Variable, Individu, MONTH - - -class eure_et_loir_eligibilite_FAJ(Variable): - value_type = bool - entity = Individu - definition_period = MONTH - label = "Éligibilité au Fond d'Aide aux Jeunes" - - def formula(individu, period, parameters): - reside_eure_et_loir = individu.menage('eure_loire_eligibilite_residence', period) - age = individu('age', period) - a_entre_18_25_ans = (age >= 18) * (age <= 25) - rsa = parameters(period).prestations.minima_sociaux.rsa - revenue_inferieur_RSA = individu('eure_et_loir_revenus_nets_du_travail', period) < rsa.montant_de_base_du_rsa - - return reside_eure_et_loir * a_entre_18_25_ans * revenue_inferieur_RSA diff --git a/openfisca_france_local/departements/eure_loire/adefip.py b/openfisca_france_local/departements/eure_loire/adefip.py deleted file mode 100644 index 2677213e..00000000 --- a/openfisca_france_local/departements/eure_loire/adefip.py +++ /dev/null @@ -1,145 +0,0 @@ -# -*- coding: utf-8 -*- -from openfisca_core import parameters -from openfisca_france.model.base import * # noqa analysis:ignore - -from numpy.core.defchararray import startswith - - -class eure_loire_eligibilite_residence(Variable): - value_type = bool - entity = Menage - definition_period = MONTH - label = u"Éligibilité résidentielle d'un ménage aux dipositifs de l'Eure et Loire" - - def formula(menage, period): - return startswith(menage('depcom', period), b'28') - - -class adefip_eligibilite_activite(Variable): - value_type = bool - entity = Individu - definition_period = MONTH - label = u"Éligibilité en lien avec l'activité de l'individu" - - def formula(individu, period, parameters): - params_adefip = parameters(period).departements.eure_loire.adefip - duree_activite = individu('duree_contrat_ou_formation', period) - - contrat_de_travail_duree = individu('contrat_de_travail_duree', period) - TypesContratDeTravailDuree = contrat_de_travail_duree.possible_values - - # cas formation - formation = individu('formation', period) - condition_formation = formation * (duree_activite >= params_adefip.durees.duree_minimum_formation) - - # cas CDD - condition_duree_cdd = duree_activite >= params_adefip.durees.duree_minimum_cdd_palier1 - condition_cdd = not_(condition_formation) * (contrat_de_travail_duree == TypesContratDeTravailDuree.cdd) * condition_duree_cdd - - # cas CDI - condition_cdi = not_(condition_formation) * (contrat_de_travail_duree == TypesContratDeTravailDuree.cdi) - - return condition_formation + condition_cdd + condition_cdi - - -class adefip_eligibilite(Variable): - value_type = bool - entity = Individu - definition_period = MONTH - - def formula(individu, period): - annee_glissante = period.start.period('year').offset(-1) - - # conditions de domiciliation - residence_eure_loire = individu.menage('eure_loire_eligibilite_residence', period) - - # conditions de RSA - percoit_rsa = individu.famille('rsa', period) - - # conditions de AdéFIP - adefip_12_derniers_mois = individu('adefip', annee_glissante, options=[ADD]) - ne_percoit_pas_adefip_12_derniers_mois = (adefip_12_derniers_mois == 0) - - # conditions de CER et PPAE - avoir_cer_ppae = individu('cer_ou_ppae', period) - - # conditions d'emplois/entreprise - condition_activite = individu('adefip_eligibilite_activite', period); - condition_entreprise = not_(condition_activite) * individu('creation_ou_reprise_entreprise', period) - - return residence_eure_loire * percoit_rsa * ne_percoit_pas_adefip_12_derniers_mois * avoir_cer_ppae * (condition_activite + condition_entreprise) - - -class adefip_montant(Variable): - value_type = float - entity = Individu - definition_period = MONTH - - def formula(individu, period, parameters): - params_adefip = parameters(period).departements.eure_loire.adefip - - duree_activite = individu('duree_contrat_ou_formation', period) - - contrat_de_travail = individu('contrat_de_travail', period) - TypesContratDeTravail = contrat_de_travail.possible_values - - contrat_de_travail_duree = individu('contrat_de_travail_duree', period) - TypesContratDeTravailDuree = contrat_de_travail_duree.possible_values - - # cas formation - formation = individu('formation', period) - condition_formation = formation * ( - duree_activite >= params_adefip.durees.duree_minimum_formation) - montant_formation = condition_formation * params_adefip.montants.montant_formation_3_mois_ou_plus - - # cas creation ou reprise entreprise - condition_entreprise = not_(condition_formation) * individu('creation_ou_reprise_entreprise', period) - montant_creation_reprise_entreprise = condition_entreprise * params_adefip.montants.montant_creation_reprise_entreprise - - # cas CDD palier 1 (entre 3 et 6 mois) - est_en_cdd = contrat_de_travail_duree == TypesContratDeTravailDuree.cdd - condition_duree_cdd_palier_1_min = (duree_activite >= params_adefip.durees.duree_minimum_cdd_palier1) - condition_duree_cdd_palier_1_max = (duree_activite <= params_adefip.durees.duree_minimum_cdd_palier2) - condition_cdd_palier_1 = est_en_cdd * condition_duree_cdd_palier_1_min * condition_duree_cdd_palier_1_max - montant_cdd_palier_1 = condition_cdd_palier_1 * params_adefip.montants.montant_cdd_3_a_6_mois - - # cas CDD palier 2 (plus de 6 mois) - condition_duree_cdd_palier_2_min = (duree_activite > params_adefip.durees.duree_minimum_cdd_palier2) - condition_cdd_palier_2 = est_en_cdd * condition_duree_cdd_palier_2_min - montant_cdd_palier_2 = condition_cdd_palier_2 * params_adefip.montants.montant_cdd_6_mois_ou_plus - - montant_cdd = (montant_cdd_palier_1 + montant_cdd_palier_2) * not_(condition_formation) * not_(condition_entreprise) - - # cas CDI temps plein - est_en_cdi = contrat_de_travail_duree == TypesContratDeTravailDuree.cdi - est_a_temps_plein = contrat_de_travail == TypesContratDeTravail.temps_plein - condition_cdi_temps_plein = est_en_cdi * est_a_temps_plein - montant_cdi_temps_plein = condition_cdi_temps_plein * params_adefip.montants.montant_cdi_temps_plein - - # cas CDI temps partiel - est_a_temps_partiel = contrat_de_travail == TypesContratDeTravail.temps_partiel - condition_cdi_temps_partiel = est_en_cdi * est_a_temps_partiel - montant_cdi_temps_partiel = condition_cdi_temps_partiel * params_adefip.montants.montant_cdi_temps_partiel - - montant_cdi = (montant_cdi_temps_plein + montant_cdi_temps_partiel) * not_(condition_formation) * not_(condition_entreprise) - - montant_adefip = montant_formation + montant_cdd + montant_cdi + montant_creation_reprise_entreprise - - return montant_adefip - - -class adefip(Variable): - value_type = int - entity = Individu - definition_period = MONTH - set_input = set_input_divide_by_period - - def formula(individu, period): - - # eligibilite - eligibilite = individu('adefip_eligibilite', period) - - # montant - montant = individu('adefip_montant', period) - - return montant * eligibilite \ No newline at end of file diff --git a/openfisca_france_local/departements/eure_loire/transportsocial.py b/openfisca_france_local/departements/eure_loire/transportsocial.py deleted file mode 100644 index 1032a0dd..00000000 --- a/openfisca_france_local/departements/eure_loire/transportsocial.py +++ /dev/null @@ -1,30 +0,0 @@ -# -*- coding: utf-8 -*- -from openfisca_france.model.base import Variable, Individu, MONTH - - -class eure_et_loir_revenus_nets_du_travail(Variable): - value_type = float - entity = Individu - definition_period = MONTH - label = "Montant des revenus nets du travail" - - def formula(individu, period): - # Il faudra ajouter des revenus ici - return individu('salaire_net', period) - - -class eure_et_loir_eligibilite_transportsocial(Variable): - value_type = bool - entity = Individu - definition_period = MONTH - label = "Transport social" - - def formula(individu, period, parameters): - reside_eure_et_loir = individu.menage('eure_loire_eligibilite_residence', period) - recoit_rsa = individu.famille('rsa', period) > 0 - age = individu('age', period) - a_entre_18_25_ans = (age >= 18) * (age <= 25) - rsa = parameters(period).prestations.minima_sociaux.rsa - revenue_inferieur_RSA = individu('eure_et_loir_revenus_nets_du_travail', period) < rsa.montant_de_base_du_rsa - - return reside_eure_et_loir * (recoit_rsa + a_entre_18_25_ans * revenue_inferieur_RSA) diff --git a/openfisca_france_local/parameters/departements/eure_et_loir/adefip.yml b/openfisca_france_local/parameters/departements/eure_et_loir/adefip.yml new file mode 100644 index 00000000..684543dd --- /dev/null +++ b/openfisca_france_local/parameters/departements/eure_et_loir/adefip.yml @@ -0,0 +1,38 @@ +montants: + montant_formation_3_mois_ou_plus: + values: + 2020-01-01: + value: 500 + montant_cdd_3_a_6_mois: + values: + 2020-01-01: + value: 400 + montant_cdd_6_mois_ou_plus: + values: + 2020-01-01: + value: 500 + montant_cdi_temps_plein: + values: + 2020-01-01: + value: 600 + montant_cdi_temps_partiel: + values: + 2020-01-01: + value: 300 + montant_creation_reprise_entreprise: + values: + 2020-01-01: + value: 700 +durees: + duree_minimum_formation: + values: + 2020-01-01: + value: 3 + duree_minimum_cdd_palier1: + values: + 2020-01-01: + value: 3 + duree_minimum_cdd_palier2: + values: + 2020-01-01: + value: 6 diff --git a/openfisca_france_local/parameters/departements/eure_loire.yml b/openfisca_france_local/parameters/departements/eure_loire.yml deleted file mode 100644 index 7b628426..00000000 --- a/openfisca_france_local/parameters/departements/eure_loire.yml +++ /dev/null @@ -1,39 +0,0 @@ -adefip: - montants: - montant_formation_3_mois_ou_plus: - values: - 2020-01-01: - value: 500 - montant_cdd_3_a_6_mois: - values: - 2020-01-01: - value: 400 - montant_cdd_6_mois_ou_plus: - values: - 2020-01-01: - value: 500 - montant_cdi_temps_plein: - values: - 2020-01-01: - value: 600 - montant_cdi_temps_partiel: - values: - 2020-01-01: - value: 300 - montant_creation_reprise_entreprise: - values: - 2020-01-01: - value: 700 - durees: - duree_minimum_formation: - values: - 2020-01-01: - value: 3 - duree_minimum_cdd_palier1: - values: - 2020-01-01: - value: 3 - duree_minimum_cdd_palier2: - values: - 2020-01-01: - value: 6 \ No newline at end of file diff --git a/tests/departements/eure_et_loir/FAJ_transportsocial_pretvehicule.yml b/tests/departements/eure_et_loir/FAJ_transportsocial_pretvehicule.yml index 76c59438..4b5c98bc 100644 --- a/tests/departements/eure_et_loir/FAJ_transportsocial_pretvehicule.yml +++ b/tests/departements/eure_et_loir/FAJ_transportsocial_pretvehicule.yml @@ -5,7 +5,7 @@ salaire_net: [500, 900, 400, 1200, 500] rsa: [0, 100, 0, 300, 0] output: - eure_et_loir_eligibilite_transportsocial: [true, true, true, true, false ] + eure_et_loir_eligibilite_transport_social: [true, true, true, true, false ] - period: 2020-10 @@ -14,7 +14,7 @@ age: [22, 18, 25, 5] salaire_net: [500, 400, 1200, 200] output: - eure_et_loir_eligibilite_FAJ: [true, true, false, false ] + eure_et_loir_eligibilite_faj: [true, true, false, false ] - period: 2020-10 @@ -22,4 +22,4 @@ depcom: [28000, 31300, 28000] rsa: [150, 100, 0] output: - eure_et_loir_eligibilite_transportsocial: [true, false, false] + eure_et_loir_eligibilite_transport_social: [true, false, false] diff --git a/tests/departements/eure_et_loir/adefip.yml b/tests/departements/eure_et_loir/adefip.yml index 6de0ffdf..01ed8b97 100644 --- a/tests/departements/eure_et_loir/adefip.yml +++ b/tests/departements/eure_et_loir/adefip.yml @@ -1,133 +1,94 @@ -- period: 2019-01 +- name: Adefip - Formation + period: 2021-01 input: - rsa: [0, 410.40, 0, 410.40] - eure_et_loir_eligibilite_residence: [true, true, false, false] + depcom: 28000 + rsa: 200 + cer_ou_ppae: true + adefip: + 2020-12: 0 + 2020-11: 0 + 2020-10: 0 + 2020-09: 0 + 2020-08: 0 + 2020-07: 0 + 2020-06: 0 + 2020-05: 0 + 2020-04: 0 + 2020-03: 0 + 2020-02: 0 + 2020-01: 0 + formation: true + duree_contrat_ou_formation: 3 output: - eure_et_loir_eligibilite_adefip: [false, true, false, false] + adefip: 500 - -- name: Cas réel 1. [500€ AdéFIP attribué.] \ - En CDD plus de 6 mois, en action d'insertion de 2019-12 à 2020-03. \ - Personne seule et trois enfants. Perçoit le RSA. - period: 2020-02 - input: - individus: - cas_reel_1: - date_naissance: '1990-12-01' - enfant_1: - date_naissance: '2018-01-01' - enfant_2: - date_naissance: '2017-01-01' - enfant_3: - date_naissance: '2016-01-01' - famille: - parents: - - cas_reel_1 - enfants: [enfant_1, enfant_2, enfant_3] - rsa: - 2020-02: 333.65 - 2019-12: 704.65 - menage: - personne_de_reference: - - cas_reel_1 - enfants: [enfant_1, enfant_2, enfant_3] - depcom: 28400 - foyer_fiscal: - declarants: - - cas_reel_1 - personnes_a_charge: [enfant_1, enfant_2, enfant_3] - output: - eure_et_loir_eligibilite_residence: true - eure_et_loir_eligibilite_adefip: true - - -- name: Cas réel 2. [700€ AdéFIP attribué.] \ - En création d'entreprise en 2019-11. En couple et 3 enfants. Perçoit le RSA. - period: 2019-12 +- name: Adefip - CDD + period: 2021-01 input: - individus: - cas_reel_2: - date_naissance: '1986-09-01' - enfant_1: - date_naissance: '2012-01-01' - enfant_2: - date_naissance: '2015-01-01' - enfant_3: - date_naissance: '2016-01-01' - famille: - parents: - - cas_reel_2 - enfants: [enfant_1, enfant_2, enfant_3] - rsa: - 2019-11: 759.42 - menage: - personne_de_reference: - - cas_reel_2 - enfants: [enfant_1, enfant_2, enfant_3] - depcom: 28100 - foyer_fiscal: - declarants: - - cas_reel_2 - personnes_a_charge: [enfant_1, enfant_2, enfant_3] + depcom: [28000, 28000] + rsa: [200, 200] + cer_ou_ppae: [true, true] + adefip: + 2020-12: [0, 0] + 2020-11: [0, 0] + 2020-10: [0, 0] + 2020-09: [0, 0] + 2020-08: [0, 0] + 2020-07: [0, 0] + 2020-06: [0, 0] + 2020-05: [0, 0] + 2020-04: [0, 0] + 2020-03: [0, 0] + 2020-02: [0, 0] + 2020-01: [0, 0] + contrat_de_travail_duree: [cdd, cdd] + duree_contrat_ou_formation: [6, 7] output: - eure_et_loir_eligibilite_residence: true - eure_et_loir_eligibilite_adefip: true - + adefip: [400, 500] -- name: Cas réel 3. AdéFIP non attribuée. \ - A déjà bénéficié de l'AdéFIP en mars 2019 et formation 2019-12 à 2020-03 non qualifiante. \ - Personne seule. Perçoit le RSA. - period: 2020-02 +- name: Adefip - CDI + period: 2021-01 input: - individus: - cas_reel_3: - date_naissance: '1988-08-01' - eure_et_loir_adefip_versee: true - famille: - parents: - - cas_reel_3 - rsa: - 2020-01: 705.27 - menage: - personne_de_reference: - - cas_reel_3 - depcom: 28000 - foyer_fiscal: - declarants: - - cas_reel_3 + depcom: [28000, 28000] + rsa: [200, 200] + cer_ou_ppae: [true, true] + adefip: + 2020-12: [0, 0] + 2020-11: [0, 0] + 2020-10: [0, 0] + 2020-09: [0, 0] + 2020-08: [0, 0] + 2020-07: [0, 0] + 2020-06: [0, 0] + 2020-05: [0, 0] + 2020-04: [0, 0] + 2020-03: [0, 0] + 2020-02: [0, 0] + 2020-01: [0, 0] + contrat_de_travail_duree: [cdi, cdi] + contrat_de_travail: [temps_plein, temps_partiel] output: - eure_et_loir_eligibilite_residence: true - eure_et_loir_eligibilite_adefip: false + adefip: [600, 300] -- name: Cas réel 4. [400€ AdéFIP attribué.] \ - En CDD de 3-6mois. En action d'insertionde 2019-12 à 04-2020. \ - Personne seule. Perçoit le RSA. - period: 2020-02 +- name: Adefip - Entreprise + period: 2021-01 input: - individus: - cas_reel_4: - date_naissance: '1968-06-01' - enfant_1: - date_naissance: '2012-01-01' - enfant_2: - date_naissance: '2015-01-01' - enfant_3: - date_naissance: '2016-01-01' - famille: - parents: - - cas_reel_4 - enfants: [enfant_1, enfant_2, enfant_3] - rsa: - 2019-12: 559.74 - menage: - personne_de_reference: - - cas_reel_4 - enfants: [enfant_1, enfant_2, enfant_3] - depcom: 28000 - foyer_fiscal: - declarants: - - cas_reel_4 - personnes_a_charge: [enfant_1, enfant_2, enfant_3] + depcom: 28000 + rsa: 200 + cer_ou_ppae: true + adefip: + 2020-12: 0 + 2020-11: 0 + 2020-10: 0 + 2020-09: 0 + 2020-08: 0 + 2020-07: 0 + 2020-06: 0 + 2020-05: 0 + 2020-04: 0 + 2020-03: 0 + 2020-02: 0 + 2020-01: 0 + creation_ou_reprise_entreprise: true output: - eure_et_loir_eligibilite_residence: true - eure_et_loir_eligibilite_adefip: true + adefip: 700 From e7ed6d596ac1748e5accbf90f7f19809b5a6ca5c Mon Sep 17 00:00:00 2001 From: TOMAS Frederic Date: Tue, 11 Jul 2023 09:14:54 +0200 Subject: [PATCH 4/6] =?UTF-8?q?D=C3=A9place=204=20variables=20de=20Openfis?= =?UTF-8?q?ca-france=20vers=20openfisca-france-local=20variables=20utilis?= =?UTF-8?q?=C3=A9es=20uniquement=20dans=20l'aide=20locale=20adefip?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../departements/eure_et_loir/adefip.py | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/openfisca_france_local/departements/eure_et_loir/adefip.py b/openfisca_france_local/departements/eure_et_loir/adefip.py index 20e956c5..a409f553 100644 --- a/openfisca_france_local/departements/eure_et_loir/adefip.py +++ b/openfisca_france_local/departements/eure_et_loir/adefip.py @@ -152,3 +152,35 @@ def formula(individu, period): montant = individu('adefip_montant', period) return montant * eligibilite + +# données "nationales" mais utilisées uniquement dans l'aide adefip aujourd'hui +class cer_ou_ppae(Variable): + value_type = bool + entity = Individu + label = "Avoir un CER (Contrat d’engagement réciproque) et/ou un PPAE (Projet personnalisé d’accès à l’emploi) en cours" + definition_period = MONTH + set_input = set_input_dispatch_by_period + + +class formation(Variable): + value_type = bool + entity = Individu + label = "Etre en formation" + definition_period = MONTH + set_input = set_input_dispatch_by_period + + +class duree_contrat_ou_formation(Variable): + value_type = int + entity = Individu + label = "Durée en mois du CDD ou de la formation" + definition_period = MONTH + set_input = set_input_dispatch_by_period + + +class creation_ou_reprise_entreprise(Variable): + value_type = bool + entity = Individu + label = "Etre en création ou en reprise d'entreprise" + definition_period = MONTH + set_input = set_input_dispatch_by_period From ee0342d2519c6d7ebd69b831aa6542f9845592ea Mon Sep 17 00:00:00 2001 From: TOMAS Frederic Date: Tue, 11 Jul 2023 12:00:12 +0200 Subject: [PATCH 5/6] Corrige l'utilisation de contrat_de_travail_duree --- .../departements/eure_et_loir/adefip.py | 16 ++++++++-------- tests/departements/eure_et_loir/adefip.yml | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/openfisca_france_local/departements/eure_et_loir/adefip.py b/openfisca_france_local/departements/eure_et_loir/adefip.py index a409f553..69a63a9d 100644 --- a/openfisca_france_local/departements/eure_et_loir/adefip.py +++ b/openfisca_france_local/departements/eure_et_loir/adefip.py @@ -31,8 +31,8 @@ def formula(individu, period, parameters): params_adefip = parameters(period).departements.eure_et_loir.adefip duree_activite = individu('duree_contrat_ou_formation', period) - contrat_de_travail_duree = individu('contrat_de_travail_duree', period) - TypesContratDeTravailDuree = contrat_de_travail_duree.possible_values + contrat_de_travail_type = individu('contrat_de_travail_type', period) + TypesContratDeTravailDuree = contrat_de_travail_type.possible_values # cas formation formation = individu('formation', period) @@ -41,10 +41,10 @@ def formula(individu, period, parameters): # cas CDD condition_duree_cdd = duree_activite >= params_adefip.durees.duree_minimum_cdd_palier1 condition_cdd = not_(condition_formation) * ( - contrat_de_travail_duree == TypesContratDeTravailDuree.cdd) * condition_duree_cdd + contrat_de_travail_type == TypesContratDeTravailDuree.cdd) * condition_duree_cdd # cas CDI - condition_cdi = not_(condition_formation) * (contrat_de_travail_duree == TypesContratDeTravailDuree.cdi) + condition_cdi = not_(condition_formation) * (contrat_de_travail_type == TypesContratDeTravailDuree.cdi) return condition_formation + condition_cdd + condition_cdi @@ -91,8 +91,8 @@ def formula(individu, period, parameters): contrat_de_travail = individu('contrat_de_travail', period) TypesContratDeTravail = contrat_de_travail.possible_values - contrat_de_travail_duree = individu('contrat_de_travail_duree', period) - TypesContratDeTravailDuree = contrat_de_travail_duree.possible_values + contrat_de_travail_type = individu('contrat_de_travail_type', period) + TypesContratDeTravailDuree = contrat_de_travail_type.possible_values # cas formation formation = individu('formation', period) @@ -105,7 +105,7 @@ def formula(individu, period, parameters): montant_creation_reprise_entreprise = condition_entreprise * params_adefip.montants.montant_creation_reprise_entreprise # cas CDD palier 1 (entre 3 et 6 mois) - est_en_cdd = contrat_de_travail_duree == TypesContratDeTravailDuree.cdd + est_en_cdd = contrat_de_travail_type == TypesContratDeTravailDuree.cdd condition_duree_cdd_palier_1_min = (duree_activite >= params_adefip.durees.duree_minimum_cdd_palier1) condition_duree_cdd_palier_1_max = (duree_activite <= params_adefip.durees.duree_minimum_cdd_palier2) condition_cdd_palier_1 = est_en_cdd * condition_duree_cdd_palier_1_min * condition_duree_cdd_palier_1_max @@ -120,7 +120,7 @@ def formula(individu, period, parameters): condition_entreprise) # cas CDI temps plein - est_en_cdi = contrat_de_travail_duree == TypesContratDeTravailDuree.cdi + est_en_cdi = contrat_de_travail_type == TypesContratDeTravailDuree.cdi est_a_temps_plein = contrat_de_travail == TypesContratDeTravail.temps_plein condition_cdi_temps_plein = est_en_cdi * est_a_temps_plein montant_cdi_temps_plein = condition_cdi_temps_plein * params_adefip.montants.montant_cdi_temps_plein diff --git a/tests/departements/eure_et_loir/adefip.yml b/tests/departements/eure_et_loir/adefip.yml index 01ed8b97..545fa6b1 100644 --- a/tests/departements/eure_et_loir/adefip.yml +++ b/tests/departements/eure_et_loir/adefip.yml @@ -41,7 +41,7 @@ 2020-03: [0, 0] 2020-02: [0, 0] 2020-01: [0, 0] - contrat_de_travail_duree: [cdd, cdd] + contrat_de_travail_type: [cdd, cdd] duree_contrat_ou_formation: [6, 7] output: adefip: [400, 500] @@ -65,7 +65,7 @@ 2020-03: [0, 0] 2020-02: [0, 0] 2020-01: [0, 0] - contrat_de_travail_duree: [cdi, cdi] + contrat_de_travail_type: [cdi, cdi] contrat_de_travail: [temps_plein, temps_partiel] output: adefip: [600, 300] From 72abdef2e96e81c4bf9feaa2f5dd8e35456bc11d Mon Sep 17 00:00:00 2001 From: TOMAS Frederic Date: Tue, 11 Jul 2023 14:26:50 +0200 Subject: [PATCH 6/6] Corrige une utilisation de period.start.period --- openfisca_france_local/departements/eure_et_loir/adefip.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/openfisca_france_local/departements/eure_et_loir/adefip.py b/openfisca_france_local/departements/eure_et_loir/adefip.py index 69a63a9d..d2974a63 100644 --- a/openfisca_france_local/departements/eure_et_loir/adefip.py +++ b/openfisca_france_local/departements/eure_et_loir/adefip.py @@ -1,4 +1,6 @@ # -*- coding: utf-8 -*- +from openfisca_core.periods import Period + from openfisca_france.model.base import * from numpy import logical_not as not_ @@ -55,7 +57,7 @@ class adefip_eligibilite(Variable): definition_period = MONTH def formula(individu, period): - annee_glissante = period.start.period('year').offset(-1) + annee_glissante = Period(('year', period.start, 1)).offset(-1).offset(-1, 'month') # conditions de domiciliation residence_eure_loire = individu.menage('eure_loire_eligibilite_residence', period)