In [127]:
###### from datetime import date
from openfisca_france import init_country
from openfisca_france.model.base import *
Ce correctif permet de redéfinir plusieurs fois la même variable sans provoquer d'erreur.
In [128]:
import functools
from openfisca_core.formulas import make_formula_decorator, neutralize_column
from openfisca_france.entities import entity_class_by_symbol
reference_formula = make_formula_decorator(entity_class_by_symbol = entity_class_by_symbol, update = True)
reference_input_variable = functools.partial(reference_input_variable, update = True)
In [129]:
TaxBenefitSystem = init_country()
tax_benefit_system = TaxBenefitSystem()
In [130]:
from openfisca_core import reforms
In [131]:
ReformeRevenuDeBase = reforms.make_reform(
key = 'revenu_de_base_enfants',
name = u"Réforme Revenu de base enfants",
reference = tax_benefit_system,
)
In [132]:
'''
La redistribution monétaire en faveur des familles combine 8 mécanismes principaux, sous conditions de ressources :
1- Allocations familiales – AF (de 0 à 19 ou 20 ans)
2- Majoration pour âge des AF (à partir de 14 ans)
3- Complément familial – CF (pour un 3ème enfant)
4- Allocation de rentrée scolaire – ARS (de 6 à 18 ans)
5- Allocation de base de la PAJE (de 0 à 2 ans)
6- Supplément de RSA calculé par enfant (déduit AF, CF, PAJE)
7- Réduction d’impôt pour scolarisation des enfants
8- Diminution de l’impôt par le quotient familial – QF (plafonné)
La réforme simulée ici permet de remplacer ces 8 dispositifs par la combinaison de :
A - un Revenu de Base Enfant, pour chaque enfant de 0 à l'anniversaire de ses 14 ans
B - un Revenu de Base Jeune, de 14 jusqu'à l'anniversaire de ses 25 ans
Divers montants de ces RdB doivent pouvoir être testés.
Un repère pour 2015 est 185€ pour le RdB Enfant / 230€ pour le RdB Jeune
'''
Out[132]:
In [133]:
# 1 à 7 :
ReformeRevenuDeBase.formula(neutralize_column(tax_benefit_system.column_by_name['af_base'])) # Suppression des allocations familiales
ReformeRevenuDeBase.formula(neutralize_column(tax_benefit_system.column_by_name['af'])) # Suppression des allocations familiales
ReformeRevenuDeBase.formula(neutralize_column(tax_benefit_system.column_by_name['cf'])) # Suppression du Complément familial
ReformeRevenuDeBase.formula(neutralize_column(tax_benefit_system.column_by_name['ars'])) # Suppression de l'allocation de rentrée scolaire
ReformeRevenuDeBase.formula(neutralize_column(tax_benefit_system.column_by_name['paje_base'])) # Suppression des allocations de base de la PAJE
ReformeRevenuDeBase.formula(neutralize_column(tax_benefit_system.column_by_name['ecpess'])) # Suppression de réduction d'impôts à titre des enfants à charge poursuivant leurs études secondaire ou supérieur.
ReformeRevenuDeBase.formula(neutralize_column(tax_benefit_system.column_by_name['nb_enfant_rsa'])) # Neutralisation des enfants dans les calculs liés au RSA
# ReformeRevenuDeBase.formula(neutralize_column(tax_benefit_system.column_by_name['rmi_nbp'])) # Neutralisation des enfants dans les calculs liés au RSA
Out[133]:
In [134]:
# 8 - Suppression du Quotient familial (QF)
# Le nombre de parts fiscales est recalculé en supprimant l'impact des enfants
from numpy import logical_not as not_, minimum as min_, maximum as max_
@ReformeRevenuDeBase.formula
class nbptr(SimpleFormulaColumn):
reference = FoyersFiscaux.column_by_name['nbptr']
# On enlève les enfants du calcul du nbptr (quotient_familial.enf*)
def function(self, simulation, period):
'''
Nombre de parts du foyer
'foy'
note 1 enfants et résidence alternée (formulaire 2041 GV page 10)
quotient_familial.conj : nb part associées au conjoint d'un couple marié ou pacsé
quotient_familial.inv1 : nb part supp enfants invalides (I, G)
quotient_familial.inv2 : nb part supp adultes invalides (R)
quotient_familial.not31 : nb part supp note 3 : cases W ou G pour veuf, celib ou div
quotient_familial.not32 : nb part supp note 3 : personne seule ayant élevé des enfants
quotient_familial.not41 : nb part supp adultes invalides (vous et/ou conjoint) note 4
quotient_familial.not42 : nb part supp adultes anciens combattants (vous et/ou conjoint) note 4
quotient_familial.not6 : nb part supp note 6
quotient_familial.isol : demi-part parent isolé (T)
quotient_familial.edcd : enfant issu du mariage avec conjoint décédé;
'''
period = period.start.offset('first-of', 'month').period('year')
nb_pac = simulation.calculate('nb_pac', period)
marpac = simulation.calculate('marpac', period)
celdiv = simulation.calculate('celdiv', period)
veuf = simulation.calculate('veuf', period)
jveuf = simulation.calculate('jveuf', period)
nbF = simulation.calculate('nbF', period)
nbG = simulation.calculate('nbG', period)
nbH = simulation.calculate('nbH', period)
nbI = simulation.calculate('nbI', period)
nbR = simulation.calculate('nbR', period)
nbJ = simulation.calculate('nbJ', period)
caseP = simulation.calculate('caseP', period)
caseW = simulation.calculate('caseW', period)
caseG = simulation.calculate('caseG', period)
caseE = simulation.calculate('caseE', period)
caseK = simulation.calculate('caseK', period)
caseN = simulation.calculate('caseN', period)
caseF = simulation.calculate('caseF', period)
caseS = simulation.calculate('caseS', period)
caseL = simulation.calculate('caseL', period)
caseT = simulation.calculate('caseT', period)
quotient_familial = simulation.legislation_at(period.start).ir.quotient_familial
no_pac = nb_pac == 0 # Aucune personne à charge en garde exclusive
has_pac = not_(no_pac)
no_alt = nbH == 0 # Aucun enfant à charge en garde alternée
has_alt = not_(no_alt)
# # note 2 : nombre de parts liées aux invalides (enfant + adulte)
n2 = quotient_familial.inv1 * (nbG + nbI / 2) + quotient_familial.inv2 * nbR
# # note 3 : Pas de personne à charge
# - invalide
n31a = quotient_familial.not31a * (no_pac & no_alt & caseP)
# - ancien combatant
n31b = quotient_familial.not31b * (no_pac & no_alt & (caseW | caseG))
n31 = max_(n31a, n31b)
# - personne seule ayant élevé des enfants
n32 = quotient_familial.not32 * (no_pac & no_alt & ((caseE | caseK) & not_(caseN)))
n3 = max_(n31, n32)
# # note 4 Invalidité de la personne ou du conjoint pour les mariés ou
# # jeunes veuf(ve)s
n4 = max_(quotient_familial.not41 * (1 * caseP + 1 * caseF), quotient_familial.not42 * (caseW | caseS))
# # note 5
# - enfant du conjoint décédé
n51 = quotient_familial.cdcd * (caseL & ((nbF + nbJ) > 0))
# - enfant autre et parent isolé
n52 = quotient_familial.isol * caseT * (((no_pac & has_alt) * ((nbH == 1) * 0.5 + (nbH >= 2))) + 1 * has_pac)
n5 = max_(n51, n52)
# # note 6 invalide avec personne à charge
n6 = quotient_familial.not6 * (caseP & (has_pac | has_alt))
# # note 7 Parent isolé
n7 = quotient_familial.isol * caseT * ((no_pac & has_alt) * ((nbH == 1) * 0.5 + (nbH >= 2)) + 1 * has_pac)
# # Régime des mariés ou pacsés
m = 1 + quotient_familial.conj + n2 + n4
# # veufs hors jveuf
v = 1 + n2 + n3 + n5 + n6
# # celib div
c = 1 + n2 + n3 + n6 + n7
return period, (marpac | jveuf) * m + (veuf & not_(jveuf)) * v + celdiv * c
In [135]:
# A - Création d'un Revenu de Base Enfant
@ReformeRevenuDeBase.formula
class rdb_enf(SimpleFormulaColumn):
column = FloatCol
entity_class = Individus
label = u"Revenu de Base Enfant"
def function(self, simulation, period):
period = period.start.offset('first-of', 'month').period('month')
age = simulation.calculate('age')
P = simulation.legislation_at(period.start).fam.af
bmaf = P.bmaf
return period, (age < 14) * 0.41 * bmaf
In [136]:
# B - Création d'un Revenu de Base Jeune
@ReformeRevenuDeBase.formula
class rdb_jeu(SimpleFormulaColumn):
column = FloatCol
entity_class = Individus
label = u"Revenu de Base Jeune"
def function(self, simulation, period):
period = period.start.offset('first-of', 'month').period('month')
age = simulation.calculate('age')
P = simulation.legislation_at(period.start).fam.af
bmaf = P.bmaf
return period, (age >= 14) * (age < 25) * 0.57 * bmaf
In [137]:
# BILAN : calcul du revenu disponible en ajoutant RdB Enfant et RdB Jeune
@ReformeRevenuDeBase.formula
class revdisp(SimpleFormulaColumn):
reference = Menages.column_by_name['revdisp']
def function(self, simulation, period):
'''
Revenu disponible - ménage
'men'
'''
period = period.start.offset('first-of', 'month').period('year')
rev_trav_holder = simulation.compute('rev_trav', period)
pen_holder = simulation.compute('pen', period)
rev_cap_holder = simulation.compute('rev_cap', period)
psoc_holder = simulation.compute('psoc', period)
ppe_holder = simulation.compute('ppe', period)
impo = simulation.calculate('impo', period)
rdb_enfant_holder = simulation.compute_add('rdb_enf', period)
rdb_jeune_holder = simulation.compute_add('rdb_jeu', period)
pen = self.sum_by_entity(pen_holder)
ppe = self.cast_from_entity_to_role(ppe_holder, role = VOUS)
ppe = self.sum_by_entity(ppe)
psoc = self.cast_from_entity_to_role(psoc_holder, role = CHEF)
psoc = self.sum_by_entity(psoc)
rev_cap = self.sum_by_entity(rev_cap_holder)
rev_trav = self.sum_by_entity(rev_trav_holder)
rdb_enfant = self.sum_by_entity(rdb_enfant_holder)
rdb_jeune = self.sum_by_entity(rdb_jeune_holder)
return period, rev_trav + pen + rev_cap + psoc + ppe + impo + rdb_enfant + rdb_jeune
In [138]:
reform = ReformeRevenuDeBase()
In [139]:
scenario = tax_benefit_system.new_scenario()
scenario.init_single_entity(
period = 2015,
parent1 = dict(
birth = date(1980, 1, 1),
salaire_imposable = 12000,
statmarit = u'Marié',
),
parent2 = dict(
birth = date(1980, 1, 1),
salaire_imposable = 46000,
statmarit = u'Marié',
),
enfants = [
dict(
birth = date(2010, 1, 1),
),
dict(
birth = date(2005, 1, 1),
),
dict(
birth = date(1999, 1, 1),
),
],
)
simulation = scenario.new_simulation(debug = True)
In [140]:
scenario_pauvre = tax_benefit_system.new_scenario()
scenario_pauvre.init_single_entity(
period = 2015,
parent1 = dict(
birth = date(1980, 1, 1),
salaire_imposable = 0,
statmarit = u'Marié',
),
parent2 = dict(
birth = date(1980, 1, 1),
salaire_imposable = 0,
statmarit = u'Marié',
),
enfants = [
dict(
birth = date(2010, 1, 1),
),
dict(
birth = date(2005, 1, 1),
),
dict(
birth = date(1999, 1, 1),
),
],
)
simulation_pauvre=scenario_pauvre.new_simulation(debug = True)
In [141]:
scenario_reform = reform.new_scenario()
scenario_reform.init_single_entity(
period = 2015,
parent1 = dict(
birth = date(1980, 1, 1),
salaire_imposable = 12000,
statmarit = u'Marié',
),
parent2 = dict(
birth = date(1980, 1, 1),
salaire_imposable = 46000,
statmarit = u'Marié',
),
enfants = [
dict(
birth = date(2010, 1, 1),
),
dict(
birth = date(2005, 1, 1),
),
dict(
birth = date(1999, 1, 1),
),
],
)
reform_simulation = scenario_reform.new_simulation(debug = True)
In [142]:
scenario_reform_pauvre = reform.new_scenario()
scenario_reform_pauvre.init_single_entity(
period = 2015,
parent1 = dict(
birth = date(1980, 1, 1),
salaire_imposable = 0,
statmarit = u'Marié',
),
parent2 = dict(
birth = date(1980, 1, 1),
salaire_imposable = 0,
statmarit = u'Marié',
),
enfants = [
dict(
birth = date(2010, 1, 1),
),
dict(
birth = date(2005, 1, 1),
),
dict(
birth = date(1999, 1, 1),
),
],
)
reform_pauvre = scenario_reform_pauvre.new_simulation(debug = True)
In [143]:
simulation.calculate('nbptr')
Out[143]:
In [144]:
reform_simulation.calculate('nbptr')
Out[144]:
In [145]:
simulation.calculate_add('af')
Out[145]:
In [146]:
reform_simulation.calculate_add('af')
Out[146]:
In [147]:
simulation.calculate_add('cf')
Out[147]:
In [148]:
reform_simulation.calculate_add('cf')
Out[148]:
In [149]:
simulation.calculate('ars')
Out[149]:
In [150]:
reform_simulation.calculate('ars')
Out[150]:
In [151]:
print simulation_pauvre.calculate_add('rsa', '2015-12')
print simulation_pauvre.calculate_add('rsa', '2015-02')
In [152]:
from openfisca_core import web_tools
print web_tools.get_trace_tool_link(scenario_pauvre, ["rsa"], api_url="http://api-test.openfisca.fr")
In [153]:
reform_simulation_pauvre.calculate_add('rsa', '2015-10')
Out[153]:
In [154]:
simulation.calculate('rmi_nbp', period = '2014-01')
Out[154]:
In [155]:
reform_simulation.calculate_add('rmi_nbp', period = '2014-01')
Out[155]:
In [156]:
reform_simulation.calculate_add('rdb_enf')
Out[156]:
In [157]:
reform_simulation.calculate_add('rdb_jeu')
Out[157]:
In [158]:
simulation.calculate('revdisp')
Out[158]:
In [159]:
reform_simulation.calculate('revdisp')
Out[159]:
In [160]:
simulation_pauvre.calculate('revdisp')
Out[160]:
In [161]:
reform_simulation_pauvre.calculate('revdisp')
Out[161]:
In [162]:
simulation.calculate('pfam')
Out[162]:
In [163]:
reform_simulation.calculate('pfam')
Out[163]:
In [164]:
simulation_pauvre.calculate('psoc')
Out[164]:
In [165]:
reform_simulation_pauvre.calculate('pfam')
Out[165]:
In [166]:
simulation.calculate('irpp')
Out[166]:
In [167]:
reform_simulation.calculate('irpp')
Out[167]:
In [ ]: