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

Édition du paramètre taxation_capital.prelevements_sociaux.prelevements_solidarite.produits_de_placement #2386

Open
wants to merge 6 commits into
base: wip-leximpact
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
159 changes: 159 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 Expand Up @@ -650,3 +793,19 @@ def formula(menage, period, parameters):
+ isf_ifi
+ prelevement_liberatoire_autoentrepreneur
)


class prelevement_forfaitaire_unique(Variable):
value_type = float
entity = FoyerFiscal
label = 'Prélèvement forfaitaire unique'
definition_period = YEAR

def formula_2018_01_01(foyer_fiscal, period, parameters):
return (
foyer_fiscal('prelevement_forfaitaire_unique_ir_hors_assurance_vie', period)
+ foyer_fiscal('prelevement_forfaitaire_unique_ir_sur_assurance_vie', period)
+ foyer_fiscal('prelevements_sociaux_revenus_capital_hors_csg_crds', period)
+ foyer_fiscal('csg_revenus_capital', period)
+ foyer_fiscal('crds_revenus_capital', period)
)
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging

from openfisca_france.model.base import *
from openfisca_france.model.prelevements_obligatoires.prelevements_sociaux.contributions_sociales.base import montant_csg_crds
from openfisca_france.model.prelevements_obligatoires.prelevements_sociaux.contributions_sociales.base import montant_csg_crds_bareme


log = logging.getLogger(__name__)
Expand Down Expand Up @@ -111,7 +111,7 @@ def formula(individu, period, parameters):
plafond_securite_sociale = individu('plafond_securite_sociale', period)

csg = parameters(period).prelevements_sociaux.contributions_sociales.csg
montant_csg = montant_csg_crds(
montant_csg = montant_csg_crds_bareme(
base_avec_abattement = assiette_csg_abattue,
base_sans_abattement = assiette_csg_non_abattue,
abattement_parameter = csg.activite.abattement,
Expand All @@ -135,7 +135,7 @@ def formula(individu, period, parameters):
plafond_securite_sociale = individu('plafond_securite_sociale', period)
csg_parameters = parameters(period).prelevements_sociaux.contributions_sociales.csg

montant_csg = montant_csg_crds(
montant_csg = montant_csg_crds_bareme(
base_avec_abattement = assiette_csg_abattue,
base_sans_abattement = assiette_csg_non_abattue,
abattement_parameter = csg_parameters.activite.abattement,
Expand All @@ -161,7 +161,7 @@ def formula(individu, period, parameters):

law = parameters(period)

montant_crds = montant_csg_crds(
montant_crds = montant_csg_crds_bareme(
law_node = law.prelevements_sociaux.contributions_sociales.crds,
base_avec_abattement = assiette_csg_abattue,
base_sans_abattement = assiette_csg_non_abattue,
Expand Down Expand Up @@ -418,39 +418,56 @@ def formula(individu, period):
class csg_imposable_non_salarie(Variable):
value_type = float
entity = Individu
label = 'Assiette CSG des personnes non salariées'
label = 'CSG des personnes non salariées'
definition_period = YEAR

def formula(individu, period, parameters):
assiette_csg_crds_non_salarie = individu('assiette_csg_crds_non_salarie', period)
csg = parameters(period).prelevements_sociaux.contributions_sociales.csg.activite
taux = csg.imposable.taux
return - taux * assiette_csg_crds_non_salarie

montant_csg = montant_csg_crds_bareme(
base_sans_abattement = assiette_csg_crds_non_salarie,
law_node = csg.imposable,
)

return montant_csg


class csg_deductible_non_salarie(Variable):
value_type = float
entity = Individu
label = 'Assiette CSG des personnes non salariées'
label = 'CSG des personnes non salariées'
definition_period = YEAR

def formula(individu, period, parameters):
assiette_csg_crds_non_salarie = individu('assiette_csg_crds_non_salarie', period)
csg = parameters(period).prelevements_sociaux.contributions_sociales.csg.activite
taux = csg.deductible.taux
return - taux * assiette_csg_crds_non_salarie

montant_csg = montant_csg_crds_bareme(
base_sans_abattement = assiette_csg_crds_non_salarie,
law_node = csg.deductible,
)

return montant_csg


class crds_non_salarie(Variable):
value_type = float
entity = Individu
label = 'Assiette CSG des personnes non salariées'
label = 'CRDS des personnes non salariées'
definition_period = YEAR

def formula(individu, period, parameters):
assiette_csg_crds_non_salarie = individu('assiette_csg_crds_non_salarie', period)
taux = parameters(period).prelevements_sociaux.contributions_sociales.crds.taux
return - taux * assiette_csg_crds_non_salarie

law = parameters(period)

montant_crds = montant_csg_crds_bareme(
base_sans_abattement = assiette_csg_crds_non_salarie,
law_node = law.prelevements_sociaux.contributions_sociales.crds,
)

return montant_crds


class revenus_non_salarie_nets(Variable):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,36 @@ def montant_csg_crds(base_avec_abattement = None, base_sans_abattement = None, i
+ law_node.taux_reduit * indicatrice_taux_reduit
+ law_node.taux_median * indicatrice_taux_intermediaire
) * base


def montant_csg_crds_bareme(base_avec_abattement = None, base_sans_abattement = None, indicatrice_taux_plein = None,
indicatrice_taux_intermediaire = None, indicatrice_taux_reduit = None, abattement_parameter = None, law_node = None, plafond_securite_sociale = None):
assert law_node is not None
if base_sans_abattement is None:
base_sans_abattement = 0
if base_avec_abattement is None:
base = base_sans_abattement
else:
assert plafond_securite_sociale is not None
assert abattement_parameter is not None
base = base_avec_abattement - abattement_parameter.calc(
base_avec_abattement,
factor = plafond_securite_sociale,
round_base_decimals = 2,
) + base_sans_abattement
if indicatrice_taux_plein is None and indicatrice_taux_reduit is None:
return -law_node.taux.calc(base)
elif indicatrice_taux_plein is not None and indicatrice_taux_reduit is not None and indicatrice_taux_intermediaire is None:
return -(
law_node.taux_plein.calc(base) * indicatrice_taux_plein
+ law_node.taux_reduit.calc(base) * indicatrice_taux_reduit
)
else:
assert indicatrice_taux_plein is not None
assert indicatrice_taux_reduit is not None
assert indicatrice_taux_intermediaire is not None
return -(
law_node.taux_plein.calc(base) * indicatrice_taux_plein
+ law_node.taux_reduit.calc(base) * indicatrice_taux_reduit
+ law_node.taux_median.calc(base) * indicatrice_taux_intermediaire
)
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import logging

from openfisca_france.model.base import *
from openfisca_france.model.prelevements_obligatoires.prelevements_sociaux.contributions_sociales.base import montant_csg_crds_bareme

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -318,7 +320,7 @@ class csg_glo_assimile_salaire_ir_et_ps(Variable):
def formula(individu, period, parameters):
f1tt = individu('f1tt', period)
csg_activite = parameters(period).prelevements_sociaux.contributions_sociales.csg.activite
taux = csg_activite.imposable.taux + csg_activite.deductible.taux
taux = csg_activite.imposable.taux.rates[0] + csg_activite.deductible.taux.rates[0]
return - f1tt * taux


Expand All @@ -332,10 +334,16 @@ class crds_glo_assimile_salaire_ir_et_ps(Variable):

def formula(individu, period, parameters):
f1tt = individu('f1tt', period)
return - f1tt * (
parameters(period).prelevements_sociaux.contributions_sociales.crds.taux

law = parameters(period)

montant_crds = montant_csg_crds_bareme(
base_sans_abattement = f1tt,
law_node = law.prelevements_sociaux.contributions_sociales.crds,
)

return montant_crds


class contribution_salariale_glo_assimile_salaire(Variable):
calculate_output = calculate_output_add
Expand Down Expand Up @@ -390,16 +398,18 @@ class crds_revenus_capital(Variable):

def formula(foyer_fiscal, period, parameters):
assiette_csg_revenus_capital = foyer_fiscal('assiette_csg_revenus_capital', period)
prelevements_sociaux = parameters(period).taxation_capital.prelevements_sociaux

crds_glo_assimile_salaire_ir_et_ps_i = foyer_fiscal.members('crds_glo_assimile_salaire_ir_et_ps', period)
crds_glo_assimile_salaire_ir_et_ps = foyer_fiscal.sum(crds_glo_assimile_salaire_ir_et_ps_i)

return (
- assiette_csg_revenus_capital * prelevements_sociaux.crds.produits_de_placement
+ crds_glo_assimile_salaire_ir_et_ps
law = parameters(period)

montant_crds = montant_csg_crds_bareme(
base_sans_abattement = assiette_csg_revenus_capital,
law_node = law.prelevements_sociaux.contributions_sociales.crds,
)

return (montant_crds + crds_glo_assimile_salaire_ir_et_ps)


class prelevements_sociaux_revenus_capital_hors_csg_crds(Variable):
value_type = float
Expand Down
Loading
Loading