Skip to content

Commit

Permalink
Start modifying pension_generique
Browse files Browse the repository at this point in the history
  • Loading branch information
benjello committed Nov 18, 2024
1 parent 7a573eb commit 760bb88
Show file tree
Hide file tree
Showing 12 changed files with 78 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
description: SMIG 40h
description: Smig 40h
unit: currency
values:
1995-05-01:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
description: SMIG 48h
description: Smig 48h
unit: currency
values:
1995-05-01:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
description: Age minimum de départ à la retraite anticipée
values:
1974-01-01:
value: 50.0
value: 50
metadata:
unit: year
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
description: Age légal de de départ à la retraite
values:
1974-01-01:
value: 60.0
value: 60
metadata:
unit: year
Original file line number Diff line number Diff line change
@@ -1 +1 @@
description: Pension minimale (en part de SMIG)
description: Pension minimale (en part de Smig)
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ unit: /1
values:
1974-01-01:
value: 0.5
metadata:
unit: Smig
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ unit: /1
values:
1974-01-01:
value: 0.66666
metadata:
unit: Smig
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
description: Période de remplacement de base
values:
1974-01-01:
value: 10.0
value: 10
metadata:
unit: year
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
description: Durée du stage dérogatoire
values:
1974-01-01:
value: 5.0
value: 5
metadata:
unit: year
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
description: Durée normale du stage requis
values:
1974-01-01:
value: 10.0
value: 10
metadata:
unit: year
6 changes: 6 additions & 0 deletions openfisca_tunisia_pension/units.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- name: smig
label:
one: Smig
other: Smigs
# parameter: marche_travail.salaire_minimum.smig.
ratio: true
57 changes: 50 additions & 7 deletions openfisca_tunisia_pension/variables/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,57 @@
from numpy import minimum as min_





def pension_generique(duree_assurance, sal_ref, taux_annuite_base, taux_annuite_supplementaire, duree_stage,
age_elig, periode_remplacement_base, plaf_taux_pension):
taux_pension = (
(duree_assurance < 4 * periode_remplacement_base) * (duree_assurance / 4) * taux_annuite_base
+ (duree_assurance >= 4 * periode_remplacement_base) * (
taux_annuite_base * periode_remplacement_base
+ (duree_assurance / 4 - periode_remplacement_base) * taux_annuite_supplementaire

bareme_annuite_en_trimestres = [
{
'threshold': 0,
'annuity_rate': taux_annuite_base,
},
{
'threshold': periode_remplacement_base,
'annuity_rate': taux_annuite_supplementaire,
},
{
'threshold': 40,
'annuity_rate': 0,
},
]

taux_pension_test = 0.0
first = True
for bracket in bareme_annuite_en_trimestres:
if first:
lower_threshold = bracket['threshold']
between_threshold_annuity_rate = bracket['annuity_rate']
first = False
continue

upper_threshold = bracket['threshold']

print(f'duree_assurance: {duree_assurance / 4}, lower_threshold: {lower_threshold}, upper_threshold: {upper_threshold}, taux_pension: {taux_pension_test}')
taux_pension_test += max(
0,
min(
(duree_assurance / 4 - lower_threshold),
(upper_threshold - lower_threshold)
) * between_threshold_annuity_rate
)
)
montant = min_(taux_pension, plaf_taux_pension) * sal_ref

lower_threshold = upper_threshold
between_threshold_annuity_rate = bracket['annuity_rate']

# taux_pension = (
# (duree_assurance < 4 * periode_remplacement_base) * (duree_assurance / 4) * taux_annuite_base
# + (duree_assurance >= 4 * periode_remplacement_base) * (
# taux_annuite_base * periode_remplacement_base
# + (duree_assurance / 4 - periode_remplacement_base) * taux_annuite_supplementaire
# )
# )

montant = min_(taux_pension_test, plaf_taux_pension) * sal_ref
return montant

0 comments on commit 760bb88

Please sign in to comment.