Skip to content

Commit

Permalink
Merge branch 'refacto_super_brut_to_disponible' into wip-leximpact
Browse files Browse the repository at this point in the history
  • Loading branch information
clallemand committed Jul 26, 2024
2 parents 18a5f2c + 006983b commit 156a537
Show file tree
Hide file tree
Showing 4 changed files with 425 additions and 21 deletions.
143 changes: 143 additions & 0 deletions openfisca_france/model/mesures.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,20 @@ def formula(menage, period, parameters):
+ revenus_nets_du_capital
)

def formula_2024_01_01(menage, period, parameters):
revenus_nets_menage = menage('revenus_nets_menage', period)
impots_directs = menage('impots_directs', period)

# On prend en compte les prestations sociales touchées par une famille dont le demandeur est dans le ménage
prestations_sociales_i = menage.members.famille('prestations_sociales', period) # PF de la famille auquel appartient chaque membre du ménage
prestations_sociales = menage.sum(prestations_sociales_i, role = Famille.DEMANDEUR) # On somme seulement pour les demandeurs

return (
revenus_nets_menage
+ impots_directs
+ prestations_sociales
)


class niveau_de_vie(Variable):
value_type = float
Expand All @@ -90,6 +104,63 @@ def formula(menage, period):
return revenu_disponible / uc


class revenus_nets_menage(Variable):
value_type = float
entity = Menage
label = 'Revenus nets'
definition_period = YEAR

def formula_2024_01_01(menage, period):
# revenus du travail nets
remuneration_brute_i = menage.members('remuneration_brute', period, options = [ADD])
remuneration_brute = menage.sum(remuneration_brute_i)
indemnite_compensatrice_csg_i = menage.members('indemnite_compensatrice_csg', period, options = [ADD])
indemnite_compensatrice_csg = menage.sum(indemnite_compensatrice_csg_i)
cotisations_salariales_i = menage.members('cotisations_salariales', period, options = [ADD])
cotisations_salariales = menage.sum(cotisations_salariales_i)
complementaire_sante_salarie_i = menage.members('complementaire_sante_salarie', period, options = [ADD])
complementaire_sante_salarie = menage.sum(complementaire_sante_salarie_i)
rpns_imposables_i = menage.members('rpns_imposables', period, options = [ADD])
rpns_imposables = menage.sum(rpns_imposables_i)
microentreprise_i = menage.members.foyer_fiscal('microentreprise', period, options = [ADD]) * menage.members.has_role(FoyerFiscal.DECLARANT_PRINCIPAL)
microentreprise = menage.sum(microentreprise_i)
# pensions nettes
chomage_brut_i = menage.members('chomage_brut', period, options = [ADD])
chomage_brut = menage.sum(chomage_brut_i)
retraite_brute_i = menage.members('retraite_brute', period, options = [ADD])
retraite_brute = menage.sum(retraite_brute_i)
casa_i = menage.members('casa', period, options = [ADD])
casa = menage.sum(casa_i)
pensions_rentes_complementaires = menage('pensions_rentes_complementaires', period)
# revenus nets du capital
revenus_du_capital_avant_prelevements = menage('revenus_du_capital_avant_prelevements', period)
prelevements_sociaux_revenus_capital_hors_csg_crds_f = menage.members.foyer_fiscal('prelevements_sociaux_revenus_capital_hors_csg_crds', period) * menage.members.has_role(FoyerFiscal.DECLARANT_PRINCIPAL)
prelevements_sociaux_revenus_capital_hors_csg_crds = menage.sum(prelevements_sociaux_revenus_capital_hors_csg_crds_f)

# CSG CRDS
csg_i = menage.members('csg', period)
csg = menage.sum(csg_i)
crds_hors_prestations_i = menage.members('crds_hors_prestations', period)
crds_hors_prestations = menage.sum(crds_hors_prestations_i)

return (
remuneration_brute
+ indemnite_compensatrice_csg
+ cotisations_salariales
- complementaire_sante_salarie
+ rpns_imposables
+ microentreprise
+ retraite_brute
+ casa
+ chomage_brut
+ pensions_rentes_complementaires
+ revenus_du_capital_avant_prelevements
+ prelevements_sociaux_revenus_capital_hors_csg_crds
+ csg
+ crds_hors_prestations
)


class revenus_nets_du_travail(Variable):
value_type = float
entity = Individu
Expand All @@ -103,6 +174,61 @@ def formula(individu, period):
return salaire_net + revenus_non_salarie_nets


class pensions_rentes_complementaires(Variable):
value_type = float
entity = Menage
label = 'Pensions et revenus de remplacement hors chomage et retraite'
reference = 'http://fr.wikipedia.org/wiki/Rente'
definition_period = YEAR

def formula(menage, period):
pensions_alimentaires_percues_i = menage.members('pensions_alimentaires_percues', period, options = [ADD])
pensions_alimentaires_percues = menage.sum(pensions_alimentaires_percues_i)
pensions_invalidite_i = menage.members('pensions_invalidite', period, options = [ADD])
pensions_invalidite = menage.sum(pensions_invalidite_i)

# Revenus du foyer fiscal, que l'on projette uniquement sur le 1er déclarant
pensions_alimentaires_versees_f = menage.members.foyer_fiscal('pensions_alimentaires_versees', period)
pensions_alimentaires_versees = menage.sum(pensions_alimentaires_versees_f * (menage.members.has_role(FoyerFiscal.DECLARANT_PRINCIPAL)))
rente_viagere_titre_onereux_f = menage.members.foyer_fiscal('rente_viagere_titre_onereux', period, options = [ADD])
rente_viagere_titre_onereux = menage.sum(rente_viagere_titre_onereux_f * (menage.members.has_role(FoyerFiscal.DECLARANT_PRINCIPAL)))

return (
pensions_alimentaires_percues
+ pensions_invalidite
+ pensions_alimentaires_versees
+ rente_viagere_titre_onereux
)


class revenus_du_capital_avant_prelevements(Variable):
value_type = float
entity = Menage
label = 'Revenus du capital avant prélèvements sociaux'
definition_period = YEAR

def formula_2024_01_01(menage, period):
assiette_csg_revenus_capital_f = menage.members.foyer_fiscal('assiette_csg_revenus_capital', period) * (menage.members.has_role(FoyerFiscal.DECLARANT_PRINCIPAL))
assiette_csg_revenus_capital = menage.sum(assiette_csg_revenus_capital_f)
assiette_csg_plus_values_f = menage.members.foyer_fiscal('assiette_csg_plus_values', period) * (menage.members.has_role(FoyerFiscal.DECLARANT_PRINCIPAL))
assiette_csg_plus_values = menage.sum(assiette_csg_plus_values_f)
plus_values_base_large_f = menage.members.foyer_fiscal('plus_values_base_large', period) * (menage.members.has_role(FoyerFiscal.DECLARANT_PRINCIPAL))
plus_values_base_large = menage.sum(plus_values_base_large_f)
rente_viagere_titre_onereux_net_f = menage.members.foyer_fiscal('rente_viagere_titre_onereux_net', period) * (menage.members.has_role(FoyerFiscal.DECLARANT_PRINCIPAL))
rente_viagere_titre_onereux_net = menage.sum(rente_viagere_titre_onereux_net_f)
# Ajoute les gains de levée d'options qui, pour les prélèvements sociaux, sont soumis aux mêmes taux que les salaires. Contrairement aux revenus ci-dessus, ces revenus sont individuels.
glo_assimiles_salaire_ir_et_ps_i = menage.members('f1tt', period)
glo_assimiles_salaire_ir_et_ps = menage.sum(glo_assimiles_salaire_ir_et_ps_i)

return (
assiette_csg_revenus_capital
- assiette_csg_plus_values
+ plus_values_base_large
- rente_viagere_titre_onereux_net
+ glo_assimiles_salaire_ir_et_ps
)


class pensions_nettes(Variable):
value_type = float
entity = Individu
Expand Down Expand Up @@ -578,6 +704,23 @@ def formula(famille, period, parameters):

return aah + caah + minimum_vieillesse + rsa + aefa + api + ass + psa + ppa_nette_crds + garantie_jeunes

def formula_2024_01_01(famille, period, parameters):
# Certaines réformes ayant des effets de bords nécessitent que le rsa soit calculé avant la ppa
rsa = famille('rsa', period, options = [ADD])
ppa_nette_crds = famille('ppa_nette_crds', period, options = [ADD])
aspa = famille('aspa', period, options = [ADD])
asi_i = famille.members('asi', period, options = [ADD])
asi = famille.sum(asi_i)
aah_i = famille.members('aah', period, options = [ADD])
aah = famille.sum(aah_i)
ass_i = famille.members('ass', period, options = [ADD])
ass = famille.sum(ass_i)
garantie_jeunes_i = famille.members('garantie_jeunes', period, options = [ADD])
garantie_jeunes = famille.sum(garantie_jeunes_i)
aefa = famille('aefa', period)

return rsa + ppa_nette_crds + aspa + asi + aah + ass + garantie_jeunes + aefa


class aides_logement(Variable):
value_type = float
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,36 +10,86 @@ class csg(Variable):
label = 'Contribution sociale généralisée'
definition_period = YEAR

def formula(individu, period):
csg_imposable_salaire = individu('csg_imposable_salaire', period, options = [ADD])
csg_deductible_salaire = individu('csg_deductible_salaire', period, options = [ADD])
csg_imposable_chomage = individu('csg_imposable_chomage', period, options = [ADD])
csg_deductible_chomage = individu('csg_deductible_chomage', period, options = [ADD])
csg_imposable_retraite = individu('csg_imposable_retraite', period, options = [ADD])
csg_deductible_retraite = individu('csg_deductible_retraite', period, options = [ADD])
csg_imposable_non_salarie = individu('csg_imposable_non_salarie', period, options = [ADD])
csg_deductible_non_salarie = individu('csg_deductible_non_salarie', period, options = [ADD])
def formula(individu, period, parameters):
csg_salaire = individu('csg_salaire', period, options = [ADD])
csg_chomage = individu('csg_chomage', period, options = [ADD])
csg_retraite = individu('csg_retraite', period, options = [ADD])
csg_non_salarie = individu('csg_non_salarie', period)
csg_glo_assimile_salaire_ir_et_ps = individu('csg_glo_assimile_salaire_ir_et_ps', period)
# CSG sur revenus du capital, définie à l'échelle du foyer fiscal, mais projetée sur le déclarant principal
csg_revenus_capital = individu.foyer_fiscal('csg_revenus_capital', period)
csg_revenus_capital_projetee = csg_revenus_capital * individu.has_role(FoyerFiscal.DECLARANT_PRINCIPAL)

return (
csg_imposable_salaire
+ csg_deductible_salaire
+ csg_imposable_chomage
+ csg_deductible_chomage
+ csg_imposable_retraite
+ csg_deductible_retraite
+ csg_imposable_non_salarie
+ csg_deductible_non_salarie
csg_salaire
+ csg_chomage
+ csg_retraite
+ csg_non_salarie
+ csg_glo_assimile_salaire_ir_et_ps
+ csg_revenus_capital_projetee
)

# TODO: manque CSG sur IJ et pré-retraites


class csg_salaire(Variable):
calculate_output = calculate_output_add
value_type = float
entity = Individu
label = 'CSG salaire'
definition_period = MONTH
set_input = set_input_divide_by_period

def formula(individu, period, parameters):
return (
individu('csg_deductible_salaire', period)
+ individu('csg_imposable_salaire', period)
)


class csg_non_salarie(Variable):
value_type = float
entity = Individu
label = 'CSG non salarie'
definition_period = YEAR

def formula(individu, period, parameters):
return (
individu('csg_deductible_non_salarie', period)
+ individu('csg_imposable_non_salarie', period)
)


class csg_retraite(Variable):
calculate_output = calculate_output_add
value_type = float
entity = Individu
label = 'CSG sur les retraites'
definition_period = MONTH
set_input = set_input_divide_by_period

def formula(individu, period, parameters):
return (
individu('csg_imposable_retraite', period)
+ individu('csg_deductible_retraite', period)
)


class csg_chomage(Variable):
calculate_output = calculate_output_add
value_type = float
entity = Individu
label = 'CSG sur le chomage'
definition_period = MONTH
set_input = set_input_divide_by_period

def formula(individu, period):
return (
individu('csg_imposable_chomage', period)
+ individu('csg_deductible_chomage', period)
)


class crds(Variable):
value_type = float
entity = Individu
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,7 @@ def formula(individu, period, parameters):
ircantec_salarie = individu('ircantec_salarie', period)
pension_salarie = individu('pension_salarie', period)
rafp_salarie = individu('rafp_salarie', period)
vieillesse_deplafonnee_salarie = individu('vieillesse_deplafonnee_salarie', period)
vieillesse_plafonnee_salarie = individu('vieillesse_plafonnee_salarie', period)
vieillesse_salarie = individu('vieillesse_salarie', period)

cotisations_salariales_contributives = (
# prive
Expand All @@ -167,8 +166,7 @@ def formula(individu, period, parameters):
+ contribution_equilibre_general_salarie
+ contribution_equilibre_technique_salarie
+ cotisation_exceptionnelle_temporaire_salarie
+ vieillesse_deplafonnee_salarie
+ vieillesse_plafonnee_salarie
+ vieillesse_salarie
# public
+ ircantec_salarie
+ pension_salarie
Expand Down
Loading

0 comments on commit 156a537

Please sign in to comment.