-
Notifications
You must be signed in to change notification settings - Fork 98
/
remplacement.py
345 lines (285 loc) · 13.5 KB
/
remplacement.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
# -*- coding: utf-8 -*-
from __future__ import division
import logging
from openfisca_france.model.base import *
from openfisca_france.model.prelevements_obligatoires.prelevements_sociaux.contributions_sociales.base import (
montant_csg_crds
)
log = logging.getLogger(__name__)
class TypesTauxCSGRemplacement(Enum):
__order__ = 'non_renseigne exonere taux_reduit taux_plein' # Needed to preserve the enum order in Python 2
non_renseigne = u"Non renseigné/non pertinent"
exonere = u"Exonéré"
taux_reduit = u"Taux réduit"
taux_plein = u"Taux plein"
class taux_csg_remplacement(Variable):
default_value = TypesTauxCSGRemplacement.taux_plein
value_type = Enum
possible_values = TypesTauxCSGRemplacement
entity = Individu
label = u"Taux retenu sur la CSG des revenus de remplacment"
definition_period = MONTH
def formula_2015(individu, period, parameters):
rfr = individu.foyer_fiscal('rfr', period = period.n_2, max_nb_cycles = 1)
nbptr = individu.foyer_fiscal('nbptr', period = period.n_2)
seuils = parameters(period.start).prelevements_sociaux.contributions.csg.remplacement.pensions_de_retraite_et_d_invalidite
seuil_exoneration = seuils.seuil_de_rfr_1 + (nbptr - 1) * seuils.demi_part_suppl
seuil_reduction = seuils.seuil_de_rfr_2 + (nbptr - 1) * seuils.demi_part_suppl
taux_csg_remplacement = where(
rfr <= seuil_exoneration,
TypesTauxCSGRemplacement.exonere,
where(
rfr <= seuil_reduction,
TypesTauxCSGRemplacement.taux_reduit,
TypesTauxCSGRemplacement.taux_plein,
)
)
return taux_csg_remplacement
# def formula_1991_02_01(individu, period, parameters):
# Hack because it goes too far in the past
# irpp = individu.foyer_fiscal('irpp', period = period.n_2, max_nb_cycles = 1)
# taux_csg_remplacement = where(
# irpp <= parameters(period.start).prelevements_sociaux.contributions.csg.remplacement.pensions_de_retraite_et_d_invalidite.seuil_d_ir,
# TypesTauxCSGRemplacement.exonere,
# TypesTauxCSGRemplacement.taux_plein,
# )
# return taux_csg_remplacement
# Allocations chômage
class csg_deductible_chomage(Variable):
calculate_output = calculate_output_add
value_type = float
entity = Individu
label = u"CSG déductible sur les allocations chômage"
reference = u"http://vosdroits.service-public.fr/particuliers/F2329.xhtml"
definition_period = MONTH
def formula(individu, period, parameters):
chomage_brut = individu('chomage_brut', period)
csg_imposable_chomage = individu('csg_imposable_chomage', period)
taux_csg_remplacement = individu('taux_csg_remplacement', period)
parameters = parameters(period.start)
montant_csg = montant_csg_crds(
base_avec_abattement = chomage_brut,
indicatrice_taux_plein = (taux_csg_remplacement == TypesTauxCSGRemplacement.taux_plein),
indicatrice_taux_reduit = (taux_csg_remplacement == TypesTauxCSGRemplacement.taux_reduit),
law_node = parameters.prelevements_sociaux.contributions.csg.chomage.deductible,
plafond_securite_sociale = parameters.cotsoc.gen.plafond_securite_sociale,
)
nbh_travail = 35 * 52 / 12 # = 151.67 # TODO: depuis 2001 mais avant ?
cho_seuil_exo = (
parameters.prelevements_sociaux.contributions.csg.chomage.min_exo
* nbh_travail
* parameters.cotsoc.gen.smic_h_b
)
csg_deductible_chomage = max_(
- montant_csg
- max_(cho_seuil_exo - (
chomage_brut
+ csg_imposable_chomage
+ montant_csg
), 0),
0,
)
return - csg_deductible_chomage
class csg_imposable_chomage(Variable):
calculate_output = calculate_output_add
value_type = float
entity = Individu
label = u"CSG imposable sur les allocations chômage"
reference = u"http://vosdroits.service-public.fr/particuliers/F2329.xhtml"
definition_period = MONTH
def formula(individu, period, parameters):
chomage_brut = individu('chomage_brut', period)
parameters = parameters(period.start)
montant_csg = montant_csg_crds(
base_avec_abattement = chomage_brut,
law_node = parameters.prelevements_sociaux.contributions.csg.chomage.imposable,
plafond_securite_sociale = parameters.cotsoc.gen.plafond_securite_sociale,
)
nbh_travail = 35 * 52 / 12 # = 151.67 # TODO: depuis 2001 mais avant ?
cho_seuil_exo = (
parameters.prelevements_sociaux.contributions.csg.chomage.min_exo
* nbh_travail
* parameters.cotsoc.gen.smic_h_b
)
csg_imposable_chomage = max_(- montant_csg - max_(cho_seuil_exo - (chomage_brut + montant_csg), 0), 0)
return - csg_imposable_chomage
class crds_chomage(Variable):
calculate_output = calculate_output_add
value_type = float
entity = Individu
label = u"CRDS sur les allocations chômage"
reference = u"http://www.insee.fr/fr/methodes/default.asp?page=definitions/contrib-remb-dette-sociale.htm"
definition_period = MONTH
def formula(individu, period, parameters):
chomage_brut = individu('chomage_brut', period)
csg_deductible_chomage = individu('csg_deductible_chomage', period)
csg_imposable_chomage = individu('csg_imposable_chomage', period)
taux_csg_remplacement = individu('taux_csg_remplacement', period)
law = parameters(period.start)
smic_h_b = law.cotsoc.gen.smic_h_b
# salaire_mensuel_reference = chomage_brut / .7
# heures_mensuelles = min_(salaire_mensuel_reference / smic_h_b, 35 * 52 / 12) # TODO: depuis 2001 mais avant ?
heures_mensuelles = 35 * 52 / 12
cho_seuil_exo = law.prelevements_sociaux.contributions.csg.chomage.min_exo * heures_mensuelles * smic_h_b
eligible = (
(taux_csg_remplacement == TypesTauxCSGRemplacement.taux_reduit)
+ (taux_csg_remplacement == TypesTauxCSGRemplacement.taux_plein)
)
montant_crds = montant_csg_crds(
base_avec_abattement = chomage_brut,
law_node = law.prelevements_sociaux.contributions.crds.activite,
plafond_securite_sociale = law.cotsoc.gen.plafond_securite_sociale,
) * eligible
crds_chomage = max_(
-montant_crds - max_(
cho_seuil_exo - (chomage_brut + csg_imposable_chomage + csg_deductible_chomage + montant_crds), 0
), 0
)
return -crds_chomage
class chomage_imposable(Variable):
value_type = float
unit = 'currency'
cerfa_field = {
0: u"1AP",
1: u"1BP",
2: u"1CP",
3: u"1DP",
4: u"1EP",
}
entity = Individu
label = u"Allocations chômage imposables"
set_input = set_input_divide_by_period
reference = u"http://www.insee.fr/fr/methodes/default.asp?page=definitions/chomage.htm"
definition_period = MONTH
def formula(individu, period):
chomage_brut = individu('chomage_brut', period)
csg_deductible_chomage = individu('csg_deductible_chomage', period)
return chomage_brut + csg_deductible_chomage
class chomage_net(Variable):
value_type = float
entity = Individu
label = u"Allocations chômage nettes"
set_input = set_input_divide_by_period
reference = u"http://vosdroits.service-public.fr/particuliers/N549.xhtml"
definition_period = MONTH
def formula(individu, period):
chomage_imposable = individu('chomage_imposable', period)
csg_imposable_chomage = individu('csg_imposable_chomage', period)
crds_chomage = individu('crds_chomage', period)
return chomage_imposable + csg_imposable_chomage + crds_chomage
# Pensions
class csg_deductible_retraite(Variable):
calculate_output = calculate_output_add
value_type = float
entity = Individu
label = u"CSG déductible sur les pensions de retraite"
reference = u"https://www.lassuranceretraite.fr/cs/Satellite/PUBPrincipale/Retraites/Paiement-Votre-Retraite/Prelevements-Sociaux?packedargs=null"
definition_period = MONTH
def formula(individu, period, parameters):
retraite_brute = individu('retraite_brute', period)
taux_csg_remplacement = individu('taux_csg_remplacement', period)
law = parameters(period.start)
montant_csg = montant_csg_crds(
base_sans_abattement = retraite_brute,
indicatrice_taux_plein = (taux_csg_remplacement == TypesTauxCSGRemplacement.taux_plein),
indicatrice_taux_reduit = (taux_csg_remplacement == TypesTauxCSGRemplacement.taux_reduit),
law_node = law.prelevements_sociaux.contributions.csg.retraite.deductible,
plafond_securite_sociale = law.cotsoc.gen.plafond_securite_sociale,
)
return montant_csg
class csg_imposable_retraite(Variable):
calculate_output = calculate_output_add
value_type = float
entity = Individu
label = u"CSG imposable sur les pensions de retraite"
reference = u"https://www.lassuranceretraite.fr/cs/Satellite/PUBPrincipale/Retraites/Paiement-Votre-Retraite/Prelevements-Sociaux?packedargs=null"
definition_period = MONTH
def formula(individu, period, parameters):
retraite_brute = individu('retraite_brute', period)
law = parameters(period.start)
montant_csg = montant_csg_crds(
base_sans_abattement = retraite_brute,
law_node = law.prelevements_sociaux.contributions.csg.retraite.imposable,
plafond_securite_sociale = law.cotsoc.gen.plafond_securite_sociale,
)
return montant_csg
class crds_retraite(Variable):
calculate_output = calculate_output_add
value_type = float
entity = Individu
label = u"CRDS sur les pensions de retraite"
reference = u"http://www.pensions.bercy.gouv.fr/vous-%C3%AAtes-retrait%C3%A9-ou-pensionn%C3%A9/le-calcul-de-ma-pension/les-pr%C3%A9l%C3%A8vements-effectu%C3%A9s-sur-ma-pension"
definition_period = MONTH
def formula(individu, period, parameters):
retraite_brute = individu('retraite_brute', period)
taux_csg_remplacement = individu('taux_csg_remplacement', period)
law = parameters(period.start)
montant_crds = montant_csg_crds(
base_sans_abattement = retraite_brute,
law_node = law.prelevements_sociaux.contributions.crds.retraite,
plafond_securite_sociale = law.cotsoc.gen.plafond_securite_sociale,
) * (taux_csg_remplacement == TypesTauxCSGRemplacement.exonere)
return montant_crds
class casa(Variable):
value_type = float
entity = Individu
label = u"Contribution additionnelle de solidarité et d'autonomie"
reference = u"http://www.service-public.fr/actualites/002691.html"
definition_period = MONTH
def formula_2013_04_01(individu, period, parameters):
retraite_brute = individu('retraite_brute', period = period)
taux_csg_remplacement = individu('taux_csg_remplacement', period)
contributions = parameters(period.start).prelevements_sociaux.contributions
casa = (
(taux_csg_remplacement == TypesTauxCSGRemplacement.taux_plein)
* contributions.casa.calc(retraite_brute)
)
return - casa
class retraite_imposable(Variable):
unit = 'currency'
value_type = float
cerfa_field = {
0: u"1AS",
1: u"1BS",
2: u"1CS",
3: u"1DS",
4: u"1ES",
}
entity = Individu
label = u"Retraites au sens strict imposables (rentes à titre onéreux exclues)"
set_input = set_input_divide_by_period
reference = u"http://vosdroits.service-public.fr/particuliers/F415.xhtml"
definition_period = MONTH
def formula(individu, period):
retraite_brute = individu('retraite_brute', period)
csg_deductible_retraite = individu('csg_deductible_retraite', period)
return retraite_brute + csg_deductible_retraite
class retraite_nette(Variable):
value_type = float
entity = Individu
label = u"Pensions de retraite nettes"
set_input = set_input_divide_by_period
reference = u"http://vosdroits.service-public.fr/particuliers/N20166.xhtml"
definition_period = MONTH
def formula(individu, period):
retraite_imposable = individu('retraite_imposable', period)
casa = individu('casa', period)
csg_imposable_retraite = individu('csg_imposable_retraite', period)
crds_retraite = individu('crds_retraite', period)
return retraite_imposable + csg_imposable_retraite + crds_retraite + casa
class crds_pfam(Variable):
value_type = float
entity = Famille
label = u"CRDS sur les prestations familiales)"
reference = "http://www.cleiss.fr/docs/regimes/regime_francea1.html"
definition_period = YEAR
def formula(famille, period, parameters):
af = famille('af', period, options = [ADD])
cf = famille('cf', period, options = [ADD])
asf = famille('asf', period, options = [ADD])
ars = famille('ars', period)
paje = famille('paje', period, options = [ADD])
ape = famille('ape', period, options = [ADD])
apje = famille('apje', period, options = [ADD])
taux_crds = parameters(period.start).prelevements_sociaux.contributions.crds.taux
return -(af + cf + asf + ars + paje + ape + apje) * taux_crds