diff --git a/openfisca_tunisia_pension/parameters/retraite/cnrps/age_legal/civil/enseignants_du_superieur.yaml b/openfisca_tunisia_pension/parameters/retraite/cnrps/age_legal/civil/enseignants_du_superieur.yaml index 473d396..1524ab0 100644 --- a/openfisca_tunisia_pension/parameters/retraite/cnrps/age_legal/civil/enseignants_du_superieur.yaml +++ b/openfisca_tunisia_pension/parameters/retraite/cnrps/age_legal/civil/enseignants_du_superieur.yaml @@ -1,10 +1,13 @@ -description: Age légal de de départ à la retraite pour certains enseignants du supérieur +description: Age de départ à la retraite pour certains enseignants du supérieur values: - 1959-02-01: - value: 60 + 2019-04-01: + value: 65 metadata: unit: year documentation: |- + Loi n° 2009-20 du 13 avril 2009, portant dispositions exceptionnelles relatives à la retraite des professeurs de l’enseignement supérieur Les enseignants concernés sont: - - les professeurs de l’enseignement supérieur et les maîtres de conférences de l’enseignement supérieur aux établissements universitaires et aux établissements de recherche scientifique civils et militaires, + - les professeurs de l’enseignement supérieur et les maîtres de conférences de l’enseignement supérieur rattachés aux établissements universitaires et aux établissements de recherche scientifique civils et militaires - les professeurs hospitalo-universitaires et les maîtres de conférences agrégés hospitalo-universitaires + + Néanmoins, ils peuvent être maintenus en activité par décret jusqu’à l’âge de soixante-dix (70) ans au maximum. diff --git a/openfisca_tunisia_pension/parameters/retraite/cnrps/age_legal/civil/index.yaml b/openfisca_tunisia_pension/parameters/retraite/cnrps/age_legal/civil/index.yaml new file mode 100644 index 0000000..f852b9b --- /dev/null +++ b/openfisca_tunisia_pension/parameters/retraite/cnrps/age_legal/civil/index.yaml @@ -0,0 +1,7 @@ +description: Âge de départ à la retraite dans le service public civil +metadata: + short_label: Âge de départ des civils + order: + - cadre_commun + - cadre_actifs + - ensegnants_du_superieur diff --git a/openfisca_tunisia_pension/parameters/retraite/cnrps/age_legal/index.yaml b/openfisca_tunisia_pension/parameters/retraite/cnrps/age_legal/index.yaml new file mode 100644 index 0000000..879694e --- /dev/null +++ b/openfisca_tunisia_pension/parameters/retraite/cnrps/age_legal/index.yaml @@ -0,0 +1,6 @@ +description: Âge de départ à la retraite +metadata: + short_label: Âge de départ + order: + - civil + - militaire diff --git a/openfisca_tunisia_pension/parameters/retraite/rsna/index.yaml b/openfisca_tunisia_pension/parameters/retraite/rsna/index.yaml index 25c6e14..697be71 100644 --- a/openfisca_tunisia_pension/parameters/retraite/rsna/index.yaml +++ b/openfisca_tunisia_pension/parameters/retraite/rsna/index.yaml @@ -1 +1,10 @@ -description: Régime des salariés non agricoles +description: Régime des salariés non agricoles (RSNA) +metadata: + short_label: RSNA + order: + - age_legal + - age_dep_anticipe + - stage_requis + - stage_derog + - bareme_annuite + - pension_minimale diff --git a/openfisca_tunisia_pension/parameters/retraite/rsna/pension_minimale/inf.yaml b/openfisca_tunisia_pension/parameters/retraite/rsna/pension_minimale/inf.yaml index 56c1af8..5df32b9 100644 --- a/openfisca_tunisia_pension/parameters/retraite/rsna/pension_minimale/inf.yaml +++ b/openfisca_tunisia_pension/parameters/retraite/rsna/pension_minimale/inf.yaml @@ -4,4 +4,4 @@ values: 1974-01-01: value: 0.5 metadata: - unit: Smig + unit: smig diff --git a/openfisca_tunisia_pension/parameters/retraite/rsna/pension_minimale/sup.yaml b/openfisca_tunisia_pension/parameters/retraite/rsna/pension_minimale/sup.yaml index 6c6433d..e258635 100644 --- a/openfisca_tunisia_pension/parameters/retraite/rsna/pension_minimale/sup.yaml +++ b/openfisca_tunisia_pension/parameters/retraite/rsna/pension_minimale/sup.yaml @@ -4,4 +4,4 @@ values: 1974-01-01: value: 0.66666 metadata: - unit: Smig + unit: smig diff --git a/openfisca_tunisia_pension/regimes/cnrps.py b/openfisca_tunisia_pension/regimes/cnrps.py index 189400b..305262f 100644 --- a/openfisca_tunisia_pension/regimes/cnrps.py +++ b/openfisca_tunisia_pension/regimes/cnrps.py @@ -58,6 +58,49 @@ class RegimeCNRPS(AbstractRegimeEnAnnuites): variable_prefix = 'cnrps' parameters_prefix = 'cnrps' + class eligible(Variable): + value_type = bool + entity = Individu + label = "L'individu est éligible à une pension CNRPS" + definition_period = YEAR + + def formula(individu, period, parameters): + duree_assurance = individu('regime_name_duree_assurance', period = period) + salaire_de_reference = individu('regime_name_salaire_de_reference', period = period) + age = individu('age', period = period) + cnrps = parameters(period).retraite.regime_name + duree_de_service_minimale_accomplie = duree_assurance > 4 * cnrps.duree_de_service_minimale + critere_age_verifie = age >= cnrps.age_legal.civil.cadre_commun + return duree_de_service_minimale_accomplie * critere_age_verifie * (salaire_de_reference > 0) + + class pension_minimale(Variable): + value_type = float + default_value = 0 # Pas de pension minimale par défaut, elle est à zéro + entity = Individu + definition_period = YEAR + label = 'Pension minimale' + + def formula(individu, period, parameters): + cnrps = parameters(period).retraite.regime_name + pension_minimale = cnrps.pension_minimale + duree_de_service_minimale = cnrps.duree_de_service_minimale + # TODO Annualiser le Smig + smig_annuel = 12 * parameters(period).marche_travail.smig_40h_mensuel + duree_assurance = individu('regime_name_duree_assurance', period) + return apply_thresholds( + duree_assurance / 4, + [ + pension_minimale.duree_service_allocation_vieillesse, + duree_de_service_minimale, + ], + [ + 0, + pension_minimale.allocation_vieillesse * smig_annuel, + pension_minimale.minimum_garanti * smig_annuel, + ] + + ) + class salaire_de_reference_calcule_sur_demande(Variable): value_type = bool entity = Individu @@ -79,11 +122,11 @@ def formula(individu, period): moyenne_2_salaires_plus_eleves = apply_along_axis( mean_over_largest, axis = 0, - arr = vstack([individu('regime_name_salaire_de_base', period = year) for year in range(period.start.year, period.start.year - n, -1)]), + arr = vstack([individu('regime_name_salaire_de_base', period = year, options = [ADD]) for year in range(period.start.year, period.start.year - n, -1)]), ) p = 3 moyenne_3_derniers_salaires = sum( - individu('regime_name_salaire_de_base', period = year) + individu('regime_name_salaire_de_base', period = year, options = [ADD]) for year in range(period.start.year, period.start.year - p, -1) ) / p @@ -94,55 +137,15 @@ def formula(individu, period): ) return salaire_refererence - # class pension_maximale(Variable): - # value_type = float - # default_value = np.inf # Pas de pension maximale par défaut - # entity = Individu - # definition_period = YEAR - # label = 'Pension maximale' - - # def formula(individu, period, parameters): - # NotImplementedError - - class pension_minimale(Variable): + class bonifications(Variable): value_type = float - default_value = 0 # Pas de pension minimale par défaut, elle est à zéro entity = Individu + label = 'Bonifications' definition_period = YEAR - label = 'Pension minimale' - def formula(individu, period, parameters): - cnrps = parameters(period).retraite.regime_name - pension_minimale = cnrps.pension_minimale - duree_de_service_minimale = cnrps.duree_de_service_minimale - # TODO Annualiser le Smig - smig_annuel = 12 * parameters(period).marche_travail.smig_40h_mensuel - duree_assurance = individu('regime_name_duree_assurance', period) - return apply_thresholds( - duree_assurance / 4, - [ - pension_minimale.duree_service_allocation_vieillesse, - duree_de_service_minimale, - ], - [ - 0, - pension_minimale.allocation_vieillesse * smig_annuel, - pension_minimale.minimum_garanti * smig_annuel, - ] + def formula(individu, period): + return ( + individu('bonfication_retraite_pour_limite_d_age', period), + + individu('bonfication_retraite_avant_age_legal', period) ) - - class eligible(Variable): - value_type = bool - entity = Individu - label = "L'individu est éligible à une pension CNRPS" - definition_period = YEAR - - def formula(individu, period, parameters): - duree_assurance = individu('regime_name_duree_assurance', period = period) - salaire_de_reference = individu('regime_name_salaire_de_reference', period = period) - age = individu('age', period = period) - cnrps = parameters(period).retraite.regime_name - duree_de_service_minimale_accomplie = duree_assurance > 4 * cnrps.duree_de_service_minimale - critere_age_verifie = age >= cnrps.age_legal.civil.cadre_commun - return duree_de_service_minimale_accomplie * critere_age_verifie * (salaire_de_reference > 0) diff --git a/openfisca_tunisia_pension/regimes/regime.py b/openfisca_tunisia_pension/regimes/regime.py index ab7db87..6eae8f3 100644 --- a/openfisca_tunisia_pension/regimes/regime.py +++ b/openfisca_tunisia_pension/regimes/regime.py @@ -189,7 +189,7 @@ def formula(individu, period, parameters): class salaire_de_base(Variable): value_type = float entity = Individu - definition_period = YEAR + definition_period = MONTH label = 'Salaire de base (salaire brut)' set_input = set_input_divide_by_period diff --git a/openfisca_tunisia_pension/regimes/rsna.py b/openfisca_tunisia_pension/regimes/rsna.py index 357b6d3..d7c2b3f 100644 --- a/openfisca_tunisia_pension/regimes/rsna.py +++ b/openfisca_tunisia_pension/regimes/rsna.py @@ -92,7 +92,7 @@ def formula(individu, period): mean_over_largest, axis = 0, arr = vstack([ - individu('regime_name_salaire_de_base', period = year) + individu('regime_name_salaire_de_base', period = year, options = [ADD]) for year in range(period.start.year, period.start.year - n, -1) ]), ) diff --git a/openfisca_tunisia_pension/variables/cnrps.py b/openfisca_tunisia_pension/variables/cnrps.py index 2576439..207a7d6 100644 --- a/openfisca_tunisia_pension/variables/cnrps.py +++ b/openfisca_tunisia_pension/variables/cnrps.py @@ -10,6 +10,15 @@ from numpy import apply_along_axis, vstack from openfisca_tunisia_pension.tools import make_mean_over_consecutive_largest +class cnrps_bonifications(Variable): + value_type = float + entity = Individu + label = 'Bonifications' + definition_period = YEAR + + def formula(individu, period): + return (individu('bonfication_retraite_pour_limite_d_age', period), +individu('bonfication_retraite_avant_age_legal', period)) + class cnrps_cotisation(Variable): value_type = float entity = Individu @@ -136,7 +145,7 @@ def formula(individu, period, parameters): class cnrps_salaire_de_base(Variable): value_type = float entity = Individu - definition_period = YEAR + definition_period = MONTH label = 'Salaire de base (salaire brut)' set_input = set_input_divide_by_period @@ -151,9 +160,9 @@ def formula(individu, period): n = 40 k = 2 mean_over_largest = make_mean_over_consecutive_largest(k) - moyenne_2_salaires_plus_eleves = apply_along_axis(mean_over_largest, axis=0, arr=vstack([individu('cnrps_salaire_de_base', period=year) for year in range(period.start.year, period.start.year - n, -1)])) + moyenne_2_salaires_plus_eleves = apply_along_axis(mean_over_largest, axis=0, arr=vstack([individu('cnrps_salaire_de_base', period=year, options=[ADD]) for year in range(period.start.year, period.start.year - n, -1)])) p = 3 - moyenne_3_derniers_salaires = sum((individu('cnrps_salaire_de_base', period=year) for year in range(period.start.year, period.start.year - p, -1))) / p + moyenne_3_derniers_salaires = sum((individu('cnrps_salaire_de_base', period=year, options=[ADD]) for year in range(period.start.year, period.start.year - p, -1))) / p salaire_refererence = where(individu('cnrps_salaire_de_reference_calcule_sur_demande', period), moyenne_2_salaires_plus_eleves, moyenne_3_derniers_salaires) return salaire_refererence diff --git a/openfisca_tunisia_pension/variables/rsa.py b/openfisca_tunisia_pension/variables/rsa.py index 3ac1739..fd5051b 100644 --- a/openfisca_tunisia_pension/variables/rsa.py +++ b/openfisca_tunisia_pension/variables/rsa.py @@ -132,7 +132,7 @@ def formula(individu, period, parameters): class rsa_salaire_de_base(Variable): value_type = float entity = Individu - definition_period = YEAR + definition_period = MONTH label = 'Salaire de base (salaire brut)' set_input = set_input_divide_by_period diff --git a/openfisca_tunisia_pension/variables/rsna.py b/openfisca_tunisia_pension/variables/rsna.py index f6676a6..e67bf40 100644 --- a/openfisca_tunisia_pension/variables/rsna.py +++ b/openfisca_tunisia_pension/variables/rsna.py @@ -143,7 +143,7 @@ def formula(individu, period, parameters): class rsna_salaire_de_base(Variable): value_type = float entity = Individu - definition_period = YEAR + definition_period = MONTH label = 'Salaire de base (salaire brut)' set_input = set_input_divide_by_period @@ -157,7 +157,7 @@ def formula(individu, period): k = 10 mean_over_largest = make_mean_over_largest(k=k) n = 40 - salaire_refererence = apply_along_axis(mean_over_largest, axis=0, arr=vstack([individu('rsna_salaire_de_base', period=year) for year in range(period.start.year, period.start.year - n, -1)])) + salaire_refererence = apply_along_axis(mean_over_largest, axis=0, arr=vstack([individu('rsna_salaire_de_base', period=year, options=[ADD]) for year in range(period.start.year, period.start.year - n, -1)])) return salaire_refererence class rsna_taux_de_liquidation(Variable): diff --git a/pyproject.toml b/pyproject.toml index cb483b5..d05e1ce 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,7 +21,7 @@ requires-python = ">= 3.9" dependencies = [ "numba>=0.54,<1.0.0", 'numpy >=1.24.3, <2', - 'openfisca-core[web-api] >=41.5.0, <41.5.3', + 'openfisca-core[web-api] >=43.0.0, <44.0.0', 'scipy >= 0.12', ]