Skip to content

Commit

Permalink
Remove invalide use handicap
Browse files Browse the repository at this point in the history
  • Loading branch information
benjello committed Feb 3, 2025
1 parent 700ea35 commit 1527624
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,27 @@
from openfisca_tunisia.variables.base import *


class invalide(Variable):
value_type = bool
label = 'Invalide (handicap lourd)'
# class TypesHandicap(Enum):
# __order__ = 'neant leger intermediaire lourd'
# # Needed to preserve the enum order in Python 2
# neant = 'Néant'
# leger = 'Léger'
# intermediaire = 'Intermédiaire'
# lourd = 'Lourd'


# class handicap(Variable):
# value_type = Enum
# possible_values = TypesHandicap
# default_value = TypesHandicap.neant
# label = 'Niveau de handicap'
# entity = Individu
# definition_period = ETERNITY


class handicap(Variable):
value_type = int
default_value = 0
label = 'Niveau de handicap (0-Néant, 1-Léger, 2-intermédiraire, 3-Lourd)'
entity = Individu
definition_period = ETERNITY
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ def formula(foyer_fiscal, period):
TODO: Nombre d'enfants infirmes
'''
age = foyer_fiscal.members('age', period = period)
invalide = foyer_fiscal.members('invalide', period = period)
handicap = foyer_fiscal.members('handicap', period = period)

return 0 * age * invalide
return 0 * age * handicap


class nb_parents(Variable):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class salaire_unique(Variable):
label = 'Indicatrice de salaire unique'
definition_period = YEAR

def formula(individu, period):
def formula(menage, period):
salaire_imposable_personne_de_reference = menage.personne_de_reference('salaire_imposable', period = period)
salaire_imposable_conjoint = menage.conjoint('salaire_imposable', period = period)
return xor_(salaire_imposable_personne_de_reference > 0, salaire_imposable_conjoint > 0)
Expand Down Expand Up @@ -42,8 +42,9 @@ class prestations_familiales_enfant_a_charge(Variable):
# locales.

def formula(individu, period, parameters):
# TODO à retravailler
# age = individu('age', period)
invalide = individu('invalide', period)
handicap = individu('handicap', period)
est_enfant = individu.has_role(Menage.ENFANT)

condition_enfant = (
Expand All @@ -54,7 +55,7 @@ def formula(individu, period, parameters):
# (age_individu <= 21) * etudiant ou soeur au foyer
)

return (condition_enfant + condition_jeune_etudiant + invalide) * est_enfant
return (condition_enfant + condition_jeune_etudiant + handicap) * est_enfant


class af_nbenf(Variable):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ class amen_social_presence_handicap_lourd(Variable):

class amen_social_pas_d_achat_onereux(Variable):
value_type = bool
defautl_value = True
entity = Menage
label = 'Ménage comprenant un membre avec un handicap lourd'
label = "Ménage n'ayant pas fait d'achat onéreux"
definition_period = ETERNITY
# Critères primaires du décret 2020-317 du 19 mai 2020
# Ni le chef du ménage ni aucun membre de son ménage n’a effectué une transaction d’achat
Expand All @@ -24,8 +25,9 @@ class amen_social_pas_d_achat_onereux(Variable):

class amen_social_pas_de_residence_secondaire(Variable):
value_type = bool
defautl_value = True
entity = Menage
label = 'Ménage comprenant un membre avec un handicap lourd'
label = 'Ménage ne possédant pas de résidence secondaire'
definition_period = ETERNITY
# Critères primaires du décret 2020-317 du 19 mai 2020
# Le ménage n’est pas propriétaire d’un logement secondaire
Expand Down Expand Up @@ -127,11 +129,11 @@ def formula_2020(menage, period, parameters):
# Les enfants sont considérés comme elève dès 6 ans (pris quand ?)
# eleve = menage.members('eleve', period.this_year)
etudiant = menage.members('etudiant', period.this_year)
invalide = menage.members('invalide', period.this_year)
handicap = menage.members('handicap', period.this_year) == 3
amen_social = parameters(period).prestations.non_contributives.amen_social.supplements
condition_enfant = (age >= 6) * (age <= amen_social.limite_age_enfant) # * eleve
condition_jeune_etudiant = (age <= amen_social.limite_age_etudiant) * etudiant
enfant_a_charge = condition_enfant + condition_jeune_etudiant + invalide
enfant_a_charge = condition_enfant + condition_jeune_etudiant + handicap
return menage.sum(1 * enfant_a_charge, role = Menage.ENFANT)


Expand All @@ -143,11 +145,11 @@ class amen_social_enfants_handicapes_a_charge(Variable):

def formula_2020(menage, period, parameters):
age = menage.members('age', period)
invalide = menage.members('invalide', period.this_year)
handicap = menage.members('handicap', period.this_year) == 3
amen_social = parameters(period).prestations.non_contributives.amen_social.supplements
condition_enfant = (age >= 6) * (age <= amen_social.limite_age_enfant)
condition_jeune_etudiant = (age <= amen_social.limite_age_etudiant)
enfant_a_charge_handicape = (condition_enfant + condition_jeune_etudiant) * invalide
enfant_a_charge_handicape = (condition_enfant + condition_jeune_etudiant) * handicap
return menage.sum(enfant_a_charge_handicape, role = Menage.ENFANT)


Expand All @@ -164,7 +166,7 @@ def formula_2020(menage, period, parameters):
enfants_a_charge = menage('amen_social_enfants_a_charge', period)
enfants_handicapes_a_charge = menage('amen_social_enfants_handicapes_a_charge', period)
tmp = eligible * (
amen_socialallocation_base
amen_social.allocation_base
+ enfants_a_charge * supplements.amen_social_enfants_a_charge
+ enfants_handicapes_a_charge * supplements.amen_social_enfants_a_charge * supplements.handicap
)
Expand Down
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ classifiers = [
requires-python = ">= 3.9"
dependencies = [
"numpy >=1.24.3, <2",
"openfisca-core[web-api] >=43, <44"
"openfisca-core[web-api] >=43, <44",
]

[project.urls]
Expand Down Expand Up @@ -84,3 +84,6 @@ filterwarnings = [
"ignore:invalid value encountered in multiply:RuntimeWarning",
"ignore:divide by zero encountered in divide:RuntimeWarning",
]

[tool.uv.workspace]
members = ["openfisca-tunisia"]

0 comments on commit 1527624

Please sign in to comment.