-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #240 from openfisca/fix_appel_reforms
Rapatrie des anciennes réformes d'Openfisca France
- Loading branch information
Showing
22 changed files
with
951 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
96 changes: 96 additions & 0 deletions
96
...sca_france_data/reforms/old_openfisca_france_reforms/allocations_familiales_imposables.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import os | ||
|
||
from openfisca_france.model.base import * | ||
|
||
|
||
dir_path = os.path.join(os.path.dirname(__file__), 'parameters') | ||
|
||
|
||
def modify_parameters(parameters): | ||
file_path = os.path.join(dir_path, 'allocations_familiales_imposables.yaml') | ||
reform_parameters_subtree = load_parameter_file(name='allocations_familiales_imposables', file_path=file_path) | ||
parameters.add_child('allocations_familiales_imposables', reform_parameters_subtree) | ||
return parameters | ||
|
||
|
||
class allocations_familiales_imposables(Reform): | ||
name = 'Allocations familiales imposables' | ||
|
||
class rbg(Variable): | ||
label = 'Nouveau revenu brut global intégrant les allocations familiales' | ||
definition_period = YEAR | ||
|
||
def formula(foyer_fiscal, period, parameters): | ||
allocations_familiales_imposables = foyer_fiscal('allocations_familiales_imposables', period, options = [ADD]) | ||
deficit_ante = foyer_fiscal('deficit_ante', period) | ||
f6gh = foyer_fiscal('f6gh', period) | ||
|
||
nacc_pvce_i = foyer_fiscal.members('nacc_pvce', period) | ||
nbic_impm_i = foyer_fiscal.members('nbic_impm', period) | ||
|
||
revenu_categoriel = foyer_fiscal('revenu_categoriel', period) | ||
cga = parameters(period).impot_revenu.calcul_revenus_imposables.rpns.cga_taux2 | ||
|
||
nacc_pvce = foyer_fiscal.sum(nacc_pvce_i) | ||
return max_( | ||
0, | ||
allocations_familiales_imposables | ||
+ revenu_categoriel | ||
+ f6gh | ||
+ (foyer_fiscal.sum(nbic_impm_i) + nacc_pvce) | ||
* (1 + cga) | ||
- deficit_ante | ||
) | ||
|
||
class rfr(Variable): | ||
label = 'Nouveau revenu fiscal de référence intégrant les allocations familiales' | ||
definition_period = YEAR | ||
|
||
def formula(foyer_fiscal, period, parameters): | ||
allocations_familiales_imposables = foyer_fiscal('allocations_familiales_imposables') | ||
abattements_plus_values = foyer_fiscal('abattements_plus_values') | ||
f3vi_holder = foyer_fiscal.members('f3vi') | ||
f3vz = foyer_fiscal('f3vz') | ||
rfr_cd = foyer_fiscal('rfr_cd') | ||
rni = foyer_fiscal('rni') | ||
rpns_exon_holder = foyer_fiscal.members('rpns_exon') | ||
rfr_rvcm_abattements_a_reintegrer = foyer_fiscal('rfr_rvcm_abattements_a_reintegrer') # Supprimée en 2018 | ||
revenus_capitaux_prelevement_liberatoire = foyer_fiscal('revenus_capitaux_prelevement_liberatoire', period, options = [ADD]) # Supprimée en 2018 | ||
revenus_capitaux_prelevement_forfaitaire_unique_ir = foyer_fiscal('revenus_capitaux_prelevement_forfaitaire_unique_ir', period, options = [ADD]) # Existe à partir de 2018 | ||
microentreprise = foyer_fiscal('microentreprise') | ||
|
||
f3vi = foyer_fiscal.sum(f3vi_holder) | ||
rpns_exon = foyer_fiscal.sum(rpns_exon_holder) | ||
|
||
return ( | ||
max_(0, rni - allocations_familiales_imposables) | ||
+ rfr_cd | ||
+ rfr_rvcm_abattements_a_reintegrer | ||
+ revenus_capitaux_prelevement_liberatoire | ||
+ revenus_capitaux_prelevement_forfaitaire_unique_ir | ||
+ f3vi | ||
+ rpns_exon | ||
+ abattements_plus_values | ||
+ f3vz | ||
+ microentreprise | ||
) | ||
|
||
# TO CHECK : f3vb after 2015 (abattements sur moins-values = interdits) | ||
|
||
class allocations_familiales_imposables(Variable): | ||
value_type = float | ||
entity = FoyerFiscal | ||
label = 'Allocations familiales imposables' | ||
definition_period = YEAR | ||
|
||
def formula(foyer_fiscal, period, parameters): | ||
imposition = parameters(period).allocations_familiales_imposables.imposition | ||
af = foyer_fiscal.declarant_principal.famille('af', period, options = [ADD]) | ||
|
||
return af * imposition | ||
|
||
def apply(self): | ||
self.update_variable(self.rbg) | ||
self.update_variable(self.rfr) | ||
self.add_variable(self.allocations_familiales_imposables) | ||
self.modify_parameters(modifier_function = modify_parameters) |
66 changes: 66 additions & 0 deletions
66
openfisca_france_data/reforms/old_openfisca_france_reforms/cesthra_invalidee.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import os | ||
|
||
from openfisca_france.model.base import * | ||
|
||
from openfisca_france import entities | ||
|
||
|
||
dir_path = os.path.join(os.path.dirname(__file__), 'parameters') | ||
|
||
|
||
def modify_parameters(parameters): | ||
file_path = os.path.join(dir_path, 'cesthra_invalidite.yaml') | ||
reform_parameters_subtree = load_parameter_file(name='cesthra', file_path=file_path) | ||
parameters.add_child('cesthra', reform_parameters_subtree) | ||
return parameters | ||
|
||
|
||
class cesthra(Variable): | ||
value_type = float | ||
entity = entities.FoyerFiscal | ||
label = "Contribution exceptionnelle de solidarité sur les très hauts revenus d'activité" | ||
definition_period = YEAR | ||
# PLF 2013 (rejeté) : 'taxe à 75%' | ||
|
||
def formula(foyer_fiscal, period, parameters): | ||
salaire_imposable_i = foyer_fiscal.members('salaire_imposable', period, options = [ADD]) | ||
_cesthra = parameters(period).cesthra | ||
|
||
cesthra_i = max_(salaire_imposable_i - _cesthra.seuil, 0) * _cesthra.taux | ||
|
||
return foyer_fiscal.sum(cesthra_i) | ||
|
||
|
||
class irpp(Variable): | ||
label = 'Impôt sur le revenu des personnes physiques (réformée pour intégrer la cesthra)' | ||
definition_period = YEAR | ||
|
||
def formula(foyer_fiscal, period, parameters): | ||
''' | ||
Montant après seuil de recouvrement (hors ppe) | ||
''' | ||
iai = foyer_fiscal('iai', period) | ||
credits_impot = foyer_fiscal('credits_impot', period) | ||
acomptes_ir = foyer_fiscal('acomptes_ir', period) | ||
contribution_exceptionnelle_hauts_revenus = foyer_fiscal('contribution_exceptionnelle_hauts_revenus', period) | ||
cesthra = foyer_fiscal('cesthra', period = period) | ||
recouvrement = parameters(period).impot_revenu.calcul_impot_revenu.recouvrement | ||
|
||
pre_result = iai - credits_impot - acomptes_ir + contribution_exceptionnelle_hauts_revenus + cesthra | ||
|
||
return ( | ||
(iai > recouvrement.seuil) | ||
* ((pre_result < recouvrement.min) * (pre_result > 0) * iai * 0 | ||
+ ((pre_result <= 0) + (pre_result >= recouvrement.min)) * (- pre_result)) | ||
+ (iai <= recouvrement.seuil) * ((pre_result < 0) * (-pre_result) | ||
+ (pre_result >= 0) * 0 * iai) | ||
) | ||
|
||
|
||
class cesthra_invalidee(Reform): | ||
name = "Contribution execptionnelle sur les très hauts revenus d'activité (invalidée par le CC)" | ||
|
||
def apply(self): | ||
self.add_variable(cesthra) | ||
self.update_variable(irpp) | ||
self.modify_parameters(modifier_function = modify_parameters) |
60 changes: 60 additions & 0 deletions
60
openfisca_france_data/reforms/old_openfisca_france_reforms/de_net_a_brut.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
from openfisca_core.reforms import Reform | ||
|
||
try: | ||
from scipy.optimize import fsolve | ||
except ImportError: | ||
fsolve = None | ||
|
||
from openfisca_france import entities | ||
from openfisca_france.model.base import * | ||
|
||
|
||
def calculate_net_from(salaire_de_base, individu, period): | ||
|
||
# We're not wanting to calculate salaire_de_base again, but instead manually set it as an input variable | ||
individu.get_holder('salaire_de_base').put_in_cache(salaire_de_base, period) | ||
|
||
# Work in isolation | ||
temp_simulation = individu.simulation.clone() | ||
temp_individu = temp_simulation.individu | ||
|
||
# Force recomputing of salaire_net | ||
temp_individu.get_holder('salaire_net_a_payer').delete_arrays() | ||
|
||
net = temp_individu('salaire_net_a_payer', period)[0] | ||
|
||
return net | ||
|
||
|
||
class salaire_de_base(Variable): | ||
value_type = float | ||
entity = entities.Individu | ||
label = 'Salaire brut' | ||
definition_period = MONTH | ||
|
||
def formula(individu, period, parameters): | ||
# Calcule le salaire brut à partir du salaire net par inversion numérique. | ||
|
||
net = individu.get_holder('salaire_net_a_payer').get_array(period) | ||
|
||
if net is None: | ||
return individu.empty_array() | ||
|
||
def solve_func(net): | ||
def innerfunc(essai): | ||
return calculate_net_from(essai, individu, period) - net | ||
return innerfunc | ||
brut_calcule = fsolve( | ||
solve_func(net), | ||
net * 1.5, # on entend souvent parler cette méthode... | ||
xtol = 1 / 10 # précision | ||
) | ||
|
||
return brut_calcule | ||
|
||
|
||
class de_net_a_brut(Reform): | ||
name = 'Inversion du calcul brut -> net' | ||
|
||
def apply(self): | ||
self.update_variable(salaire_de_base) |
8 changes: 8 additions & 0 deletions
8
...ta/reforms/old_openfisca_france_reforms/parameters/allocations_familiales_imposables.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
description: Intégration au revenu imposable des allocations familiales | ||
imposition: | ||
description: "Indicatrice d'imposition" | ||
values: | ||
'2015-01-01': | ||
value: null | ||
'2000-01-01': | ||
value: true |
15 changes: 15 additions & 0 deletions
15
...fisca_france_data/reforms/old_openfisca_france_reforms/parameters/cesthra_invalidite.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
description: Contribution execptionnelle sur les très hauts revenus d'activité | ||
seuil: | ||
description: Seuil | ||
values: | ||
'2014-01-01': | ||
value: null | ||
'2012-01-01': | ||
value: 1000000 | ||
taux: | ||
description: Taux | ||
values: | ||
'2014-01-01': | ||
value: null | ||
'2012-01-01': | ||
value: 0.75 |
107 changes: 107 additions & 0 deletions
107
...sca_france_data/reforms/old_openfisca_france_reforms/parameters/landais_piketty_saez.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
description: Impôt à base large proposé par Landais Piketty et Saez | ||
bareme: | ||
unit: currency | ||
description: Barème de l'impôt | ||
brackets: | ||
- average_rate: | ||
'2015-01-01': | ||
value: null | ||
'2000-01-01': | ||
value: 0.02 | ||
threshold: | ||
'2015-01-01': | ||
value: null | ||
'2000-01-01': | ||
value: 1100 | ||
- average_rate: | ||
'2015-01-01': | ||
value: null | ||
'2000-01-01': | ||
value: 0.1 | ||
threshold: | ||
'2015-01-01': | ||
value: null | ||
'2000-01-01': | ||
value: 2200 | ||
- average_rate: | ||
'2015-01-01': | ||
value: null | ||
'2000-01-01': | ||
value: 0.13 | ||
threshold: | ||
'2015-01-01': | ||
value: null | ||
'2000-01-01': | ||
value: 5000 | ||
- average_rate: | ||
'2015-01-01': | ||
value: null | ||
'2000-01-01': | ||
value: 0.25 | ||
threshold: | ||
'2015-01-01': | ||
value: null | ||
'2000-01-01': | ||
value: 10000 | ||
- average_rate: | ||
'2015-01-01': | ||
value: null | ||
'2000-01-01': | ||
value: 0.5 | ||
threshold: | ||
'2015-01-01': | ||
value: null | ||
'2000-01-01': | ||
value: 40000 | ||
- average_rate: | ||
'2015-01-01': | ||
value: null | ||
'2000-01-01': | ||
value: 0.6 | ||
threshold: | ||
'2015-01-01': | ||
value: null | ||
'2000-01-01': | ||
value: 100000 | ||
imposition: | ||
description: "Indicatrice d'imposition" | ||
values: | ||
'2015-01-01': | ||
value: null | ||
'2000-01-01': | ||
value: true | ||
credit_enfant: | ||
description: "Crédit d'impôt forfaitaire par enfant" | ||
values: | ||
'2015-01-01': | ||
value: null | ||
'2000-01-01': | ||
value: 0 | ||
reduc_enfant: | ||
description: "Réduction d'impôt forfaitaire par enfant" | ||
values: | ||
'2015-01-01': | ||
value: null | ||
'2000-01-01': | ||
value: 0 | ||
abatt_enfant: | ||
description: Abattement forfaitaire sur le revenu par enfant | ||
values: | ||
'2015-01-01': | ||
value: null | ||
'2000-01-01': | ||
value: 0 | ||
reduc_conj: | ||
description: "Réduction d'impôt forfaitaire si conjoint" | ||
values: | ||
'2015-01-01': | ||
value: null | ||
'2000-01-01': | ||
value: 0 | ||
abatt_conj: | ||
description: Abattement forfaitaire sur le revenu si conjoint | ||
values: | ||
'2015-01-01': | ||
value: null | ||
'2000-01-01': | ||
value: 0 |
Oops, something went wrong.