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

Integration de l'Adefip et des tests associés #84

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
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
180 changes: 172 additions & 8 deletions openfisca_france_local/departements/eure_et_loir/adefip.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# -*- coding: utf-8 -*-
from numpy import logical_not as not_
from openfisca_core.periods import Period

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
Expand All @@ -10,15 +13,176 @@ 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_type = individu('contrat_de_travail_type', period)
TypesContratDeTravailDuree = contrat_de_travail_type.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_type == TypesContratDeTravailDuree.cdd) * condition_duree_cdd

# cas CDI
condition_cdi = not_(condition_formation) * (contrat_de_travail_type == 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(('year', period.start, 1)).offset(-1).offset(-1, 'month')

# 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_type = individu('contrat_de_travail_type', period)
TypesContratDeTravailDuree = contrat_de_travail_type.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_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
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_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

# 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

return not_(eure_et_loir_adefip_versee) * recoit_rsa * reside_eure_et_loir
# 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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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_transport_social: [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_transport_social: [true, false, false]
Loading