diff --git a/openfisca_france/model/prelevements_obligatoires/prelevements_sociaux/cotisations_sociales/allegements.py b/openfisca_france/model/prelevements_obligatoires/prelevements_sociaux/cotisations_sociales/allegements.py index 78b1006f09..cde0441bcf 100644 --- a/openfisca_france/model/prelevements_obligatoires/prelevements_sociaux/cotisations_sociales/allegements.py +++ b/openfisca_france/model/prelevements_obligatoires/prelevements_sociaux/cotisations_sociales/allegements.py @@ -2,6 +2,8 @@ from numpy import busday_count, datetime64, logical_or as or_, logical_and as and_, timedelta64 +from openfisca_core.periods import Period + from openfisca_france.model.base import * log = logging.getLogger(__name__) @@ -535,7 +537,7 @@ def compute_allegement_anticipe(individu, period, parameters, variable_name, com if period.start.month == 12: cumul = individu( variable_name, - period.start.offset('first-of', 'year').period('month', 11), options = [ADD]) + Period(('month', period.start.offset('first-of', 'year'), 11)), options = [ADD]) return compute_function( individu, period.this_year, parameters ) - cumul @@ -546,8 +548,8 @@ def compute_allegement_progressif(individu, period, parameters, variable_name, c return compute_function(individu, period.first_month, parameters) if period.start.month > 1: - up_to_this_month = period.start.offset('first-of', 'year').period('month', period.start.month) - up_to_previous_month = period.start.offset('first-of', 'year').period('month', period.start.month - 1) + up_to_this_month = Period(('month', period.start.offset('first-of', 'year'), period.start.month)) + up_to_previous_month = Period(('month', period.start.offset('first-of', 'year'), period.start.month - 1)) cumul = individu(variable_name, up_to_previous_month, options = [ADD]) return compute_function(individu, up_to_this_month, parameters) - cumul diff --git a/openfisca_france/model/prelevements_obligatoires/prelevements_sociaux/cotisations_sociales/base.py b/openfisca_france/model/prelevements_obligatoires/prelevements_sociaux/cotisations_sociales/base.py index fbb9be833f..940135b9e5 100644 --- a/openfisca_france/model/prelevements_obligatoires/prelevements_sociaux/cotisations_sociales/base.py +++ b/openfisca_france/model/prelevements_obligatoires/prelevements_sociaux/cotisations_sociales/base.py @@ -1,3 +1,5 @@ +from openfisca_core.periods import Period + from openfisca_france.model.base import * @@ -371,8 +373,10 @@ def compute_cotisation_anticipee(individu, period, parameters, cotisation_type = bareme_name = bareme_name, ) if period.start.month == 12: - cumul = individu(variable_name, period.start.offset('first-of', 'month').offset( - -11, 'month').period('month', 11), options = [ADD]) + cumul = individu( + variable_name, + Period(('month', period.start.offset('first-of', 'month').offset(-11, 'month'), 11)), + options = [ADD]) # December variable_name depends on variable_name in the past 11 months. # We need to explicitely allow this recursion. diff --git a/openfisca_france/model/prelevements_obligatoires/taxe_habitation/taxe_habitation.py b/openfisca_france/model/prelevements_obligatoires/taxe_habitation/taxe_habitation.py index bf0cadcde8..2f6e32c41d 100644 --- a/openfisca_france/model/prelevements_obligatoires/taxe_habitation/taxe_habitation.py +++ b/openfisca_france/model/prelevements_obligatoires/taxe_habitation/taxe_habitation.py @@ -1,3 +1,5 @@ +from openfisca_core.periods import Period + from openfisca_france.model.base import * @@ -333,7 +335,7 @@ def formula_2017_01_01(menage, period, parameters): taux_th_commune = menage('taux_th_commune', period) taux_th_epci = menage('taux_th_epci', period) ecart_avec_2000 = period.start.offset('first-of', 'year').year - 2000 - annee_2000 = period.start.offset('first-of', 'year').period('year').offset(-ecart_avec_2000) + annee_2000 = Period(('year', period.start.offset('first-of', 'year'), 1)).offset(-ecart_avec_2000) taux_th_commune_2000 = menage('taux_th_commune', annee_2000) taux_th_epci_2000 = menage('taux_th_epci', annee_2000) diff --git a/openfisca_france/model/prestations/agepi.py b/openfisca_france/model/prestations/agepi.py index aea93b0287..ef3a1ac84b 100644 --- a/openfisca_france/model/prestations/agepi.py +++ b/openfisca_france/model/prestations/agepi.py @@ -1,5 +1,7 @@ from numpy import fabs, timedelta64 +from openfisca_core.periods import Period + from openfisca_france.model.base import Famille, Individu, Variable, Enum, MONTH, ADD,\ set_input_dispatch_by_period, set_input_divide_by_period, date, min_, not_ from openfisca_france.model.revenus.activite.salarie import TypesContrat, TypesLieuEmploiFormation,\ @@ -83,7 +85,7 @@ def formula_2014_01_20(individu, period, parameters): condition_nb_enfants = individu.famille('agepi_nbenf', period) > 0 # L'individu n'a pas touché l'AGEPI dans les 12 derniers mois (condition de durée entre faits générateurs) - annee_glissante = period.start.period('year').offset(-1).offset(-1, 'month') + annee_glissante = Period(('year', period.start, 1)).offset(-1).offset(-1, 'month') agepi_non_percues = not_(individu('agepi', annee_glissante, options=[ADD])) # L'individu est inscrit en catégorie 1, 2, 3, 4 "stagiaire de la formation professionnelle" ou 5 "contrat aidé" diff --git a/openfisca_france/model/prestations/aide_mobilite.py b/openfisca_france/model/prestations/aide_mobilite.py index a7772c2ffe..63f0e6f671 100644 --- a/openfisca_france/model/prestations/aide_mobilite.py +++ b/openfisca_france/model/prestations/aide_mobilite.py @@ -1,4 +1,7 @@ from numpy import fabs, timedelta64 + +from openfisca_core.periods import Period + from openfisca_france.model.base import Individu, Variable, MONTH, Enum, not_, ADD,\ set_input_dispatch_by_period, set_input_divide_by_period, min_, date from openfisca_france.model.caracteristiques_socio_demographiques.logement import TypesLieuResidence @@ -326,7 +329,7 @@ def formula_2021_06_09(individu, period, parameters): eligibilite_amob = individu('aide_mobilite_eligible', period) parametres_amob = parameters(period).prestations_sociales.aide_mobilite - annee_glissante = period.start.period('year').offset(-1) + annee_glissante = Period(('year', period.start, 1)).offset(-1) aide_mobilite_12_derniers_mois = individu('aide_mobilite', annee_glissante, options=[ADD]) diff --git a/openfisca_france/model/prestations/aides_exceptionnelles/indemnite_inflation.py b/openfisca_france/model/prestations/aides_exceptionnelles/indemnite_inflation.py index 064536d4ef..b8894b994f 100644 --- a/openfisca_france/model/prestations/aides_exceptionnelles/indemnite_inflation.py +++ b/openfisca_france/model/prestations/aides_exceptionnelles/indemnite_inflation.py @@ -1,5 +1,7 @@ -from openfisca_france.model.base import * from openfisca_core import periods + +from openfisca_france.model.base import * + from numpy import logical_or as or_, logical_and as and_ # Les éligibilités séparées de l'indemnité inflation diff --git a/openfisca_france/model/prestations/aides_logement.py b/openfisca_france/model/prestations/aides_logement.py index 8154196b8e..a357421a11 100644 --- a/openfisca_france/model/prestations/aides_logement.py +++ b/openfisca_france/model/prestations/aides_logement.py @@ -7,9 +7,9 @@ from numpy import ceil, datetime64, fromiter, int16, logical_or as or_, logical_and as and_, logical_not as not_ -import openfisca_france -from openfisca_core.periods import Instant +from openfisca_core.periods import Instant, Period +import openfisca_france from openfisca_france.model.base import * from openfisca_france.model.revenus.activite.salarie import TypesConges from openfisca_france.model.prestations.prestations_familiales.base_ressource import nb_enf @@ -566,7 +566,7 @@ class aide_logement_base_ressources_individu(Variable): def formula_2021_01_01(individu, period, parameters): period_frais = period.last_year - annee_glissante = period.start.period('year').offset(-1).offset(-1, 'month') + annee_glissante = Period(('year', period.start, 1)).offset(-1).offset(-1, 'month') salaire_imposable = individu('salaire_imposable', annee_glissante, options=[ADD]) chomage_imposable = individu('chomage_imposable', annee_glissante, options=[ADD]) diff --git a/openfisca_france/model/prestations/autonomie.py b/openfisca_france/model/prestations/autonomie.py index 50e7ac90f8..c5833d397b 100644 --- a/openfisca_france/model/prestations/autonomie.py +++ b/openfisca_france/model/prestations/autonomie.py @@ -1,3 +1,5 @@ +from openfisca_core.periods import Period + from openfisca_france.model.base import * @@ -133,7 +135,7 @@ class apa_eligibilite(Variable): set_input = set_input_dispatch_by_period def formula_2002(individu, period, parameters): - period = period.start.offset('first-of', 'month').period('month') + period = Period(('month', period.start.offset('first-of', 'month'), 1)) parameters = parameters(period).prestations_sociales.prestations_etat_de_sante.perte_autonomie_personnes_agees age = individu('age', period) apa_age_min = parameters.apa_domicile.condition_age @@ -172,7 +174,7 @@ class apa_domicile(Variable): set_input = set_input_divide_by_period def formula_2002(individu, period, parameters): - period = period.start.offset('first-of', 'month').period('month') + period = Period(('month', period.start.offset('first-of', 'month'), 1)) apa_domicile = parameters(period).prestations_sociales.prestations_etat_de_sante.perte_autonomie_personnes_agees.apa_domicile apa_eligibilite = individu('apa_eligibilite', period) smic_brut_horaire = parameters(period).marche_travail.salaire_minimum.smic.smic_b_horaire @@ -193,7 +195,7 @@ class apa_etablissement(Variable): set_input = set_input_divide_by_period def formula_2002(individu, period, parameters): - period = period.start.offset('first-of', 'month').period('month') + period = Period(('month', period.start.offset('first-of', 'month'), 1)) perte_autonomie_personnes_agees = parameters(period).prestations_sociales.prestations_etat_de_sante.perte_autonomie_personnes_agees smic_brut_horaire = parameters(period).marche_travail.salaire_minimum.smic.smic_b_horaire seuil_non_versement = perte_autonomie_personnes_agees.apa_institution.seuil_versement_en_part_smic_brut_horaire * smic_brut_horaire @@ -350,7 +352,7 @@ class apa_urgence_institution(Variable): set_input = set_input_divide_by_period def formula_2002(individu, period, parameters): - period = period.start.offset('first-of', 'month').period('month') + period = Period(('month', period.start.offset('first-of', 'month'), 1)) dependance_tarif_etablissement_gir_1_2 = individu('dependance_tarif_etablissement_gir_1_2', period) part_urgence_institution = parameters(period).prestations_sociales.prestations_etat_de_sante.perte_autonomie_personnes_agees.apa_institution.part_tarif_dependance apa_urgence_institution = part_urgence_institution * dependance_tarif_etablissement_gir_1_2 diff --git a/openfisca_france/model/prestations/jeunes/contrat_engagement_jeune.py b/openfisca_france/model/prestations/jeunes/contrat_engagement_jeune.py index d9f49c563f..73e31c8a69 100644 --- a/openfisca_france/model/prestations/jeunes/contrat_engagement_jeune.py +++ b/openfisca_france/model/prestations/jeunes/contrat_engagement_jeune.py @@ -1,3 +1,5 @@ +from openfisca_core.periods import Period + from openfisca_france.model.base import * # noqa analysis:ignore @@ -17,7 +19,7 @@ def formula_2022_03_01(individu, period, parameters): montant_degressivite = parameters(period).prestations_sociales.aides_jeunes.contrat_engagement_jeune.degressivite.montant age = individu('age', period) majeur = individu('majeur', period) - previous_year = period.start.period('year').offset(-1) + previous_year = Period(('year', period.start, 1)).offset(-1) tranche = individu.foyer_fiscal('ir_tranche', previous_year) degressivite = majeur * (tranche > 0) * montant_degressivite @@ -91,7 +93,7 @@ def formula_2022_03_01(individu, period, parameters): niveau_ressources = (niveau_ressources_individuelles_3_mois) / 3 - previous_year = period.start.period('year').offset(-1) + previous_year = Period(('year', period.start, 1)).offset(-1) tranche = individu.foyer_fiscal('ir_tranche', previous_year) <= 1 return (niveau_ressources <= plafond) * sans_rsa * sans_ppa * tranche diff --git a/openfisca_france/model/prestations/logement_social.py b/openfisca_france/model/prestations/logement_social.py index 84fa73fd9e..6b04c9293a 100644 --- a/openfisca_france/model/prestations/logement_social.py +++ b/openfisca_france/model/prestations/logement_social.py @@ -1,7 +1,7 @@ from numpy import isin, logical_not as not_, select from openfisca_core.indexed_enums import Enum -from openfisca_core.periods import MONTH +from openfisca_core.periods import MONTH, Period from openfisca_core.variables import Variable from openfisca_france.entities import Famille, Menage @@ -172,7 +172,7 @@ class logement_social_eligible(Variable): def formula_2017(famille, period, parameters): parent_majeur = famille.any(famille.members('majeur', period), role = Famille.PARENT) logement_social_plafond_ressources = famille('logement_social_plafond_ressources', period) - rfr_n0 = famille.demandeur.foyer_fiscal('rfr', period.start.offset('first-of', 'year').period('year')) + rfr_n0 = famille.demandeur.foyer_fiscal('rfr', Period(('year', period.start.offset('first-of', 'year'), 1))) rfr_n1 = famille.demandeur.foyer_fiscal('rfr', period.last_year) rfr_n2 = famille.demandeur.foyer_fiscal('rfr', period.n_2) diff --git a/openfisca_france/model/prestations/minima_sociaux/aah.py b/openfisca_france/model/prestations/minima_sociaux/aah.py index f4c02d6e32..3c3ec5376c 100644 --- a/openfisca_france/model/prestations/minima_sociaux/aah.py +++ b/openfisca_france/model/prestations/minima_sociaux/aah.py @@ -1,3 +1,5 @@ +from openfisca_core.periods import Period + from openfisca_france.model.base import * from numpy import datetime64 @@ -105,7 +107,7 @@ def assiette_revenu_activite_demandeur(revenus_demandeur): return (1 - aah.travail_ordinaire.abattement_30) * total_tranche1 + (1 - aah.travail_ordinaire.abattement_sup) * total_tranche2 def base_ressource_eval_trim(): - three_previous_months = period.first_month.start.period('month', 3).offset(-3) + three_previous_months = Period(('month', period.first_month.start, 3)).offset(-3) base_ressource_activite = individu('aah_base_ressources_activite_eval_trimestrielle', period) - individu('aah_base_ressources_activite_milieu_protege', three_previous_months, options = [ADD]) base_ressource_hors_activite = individu('aah_base_ressources_hors_activite_eval_trimestrielle', period) + individu('aah_base_ressources_activite_milieu_protege', three_previous_months, options = [ADD]) @@ -151,7 +153,7 @@ def assiette_revenu_activite_demandeur(revenus_demandeur): return (1 - aah.travail_ordinaire.abattement_30) * total_tranche1 + (1 - aah.travail_ordinaire.abattement_sup) * total_tranche2 def base_ressource_eval_trim(): - three_previous_months = period.first_month.start.period('month', 3).offset(-3) + three_previous_months = Period(('month', period.first_month.start, 3)).offset(-3) base_ressource_activite = individu('aah_base_ressources_activite_eval_trimestrielle', period) - individu('aah_base_ressources_activite_milieu_protege', three_previous_months, options = [ADD]) base_ressource_hors_activite = individu('aah_base_ressources_hors_activite_eval_trimestrielle', period) + individu('aah_base_ressources_activite_milieu_protege', three_previous_months, options = [ADD]) @@ -192,7 +194,7 @@ def assiette_revenu_activite_demandeur(revenus_demandeur): return (1 - aah.travail_ordinaire.abattement_30) * total_tranche1 + (1 - aah.travail_ordinaire.abattement_sup) * total_tranche2 def base_ressource_eval_trim(): - three_previous_months = period.first_month.start.period('month', 3).offset(-3) + three_previous_months = Period(('month', period.first_month.start, 3)).offset(-3) base_ressource_activite = individu('aah_base_ressources_activite_eval_trimestrielle', period) - individu('aah_base_ressources_activite_milieu_protege', three_previous_months, options = [ADD]) base_ressource_hors_activite = individu('aah_base_ressources_hors_activite_eval_trimestrielle', period) + individu('aah_base_ressources_activite_milieu_protege', three_previous_months, options = [ADD]) @@ -239,7 +241,7 @@ class aah_base_ressources_activite_eval_trimestrielle(Variable): def formula(individu, period): period = period.first_month - three_previous_months = period.start.period('month', 3).offset(-3) + three_previous_months = Period(('month', period.start, 3)).offset(-3) last_year = period.last_year ressources_a_inclure = [ @@ -299,7 +301,7 @@ class aah_base_ressources_hors_activite_eval_trimestrielle(Variable): def formula(individu, period): period = period.first_month - three_previous_months = period.start.period('month', 3).offset(-3) + three_previous_months = Period(('month', period.start, 3)).offset(-3) ressources_a_inclure = [ 'asi', @@ -564,7 +566,7 @@ class eligibilite_caah(Variable): set_input = set_input_dispatch_by_period def formula_2015_07_01(individu, period, parameters): - annee_precedente = period.start.period('year').offset(-1) + annee_precedente = Period(('year', period.start, 1)).offset(-1) prestations = parameters(period).prestations_sociales taux_incapacite_min = prestations.prestations_etat_de_sante.invalidite.aah.taux_capacite.taux_incapacite aah = individu('aah', period) @@ -606,7 +608,7 @@ def formula_2015_07_01(individu, period, parameters): def formula_2005_07_01(individu, period, parameters): invalidite = parameters(period).prestations_sociales.prestations_etat_de_sante.invalidite - annee_precedente = period.start.period('year').offset(-1) + annee_precedente = Period(('year', period.start, 1)).offset(-1) activite_12_mois = individu('salaire_imposable', annee_precedente, options = [ADD]) + individu('rpns_imposables', annee_precedente) garantie_ressources = invalidite.caah.garantie_ressources diff --git a/openfisca_france/model/prestations/minima_sociaux/asi_aspa.py b/openfisca_france/model/prestations/minima_sociaux/asi_aspa.py index 5a691c3ca5..44f675b56e 100644 --- a/openfisca_france/model/prestations/minima_sociaux/asi_aspa.py +++ b/openfisca_france/model/prestations/minima_sociaux/asi_aspa.py @@ -1,5 +1,7 @@ from numpy import abs as abs_, logical_or as or_ +from openfisca_core.periods import Period + from openfisca_france.model.base import * @@ -147,7 +149,7 @@ class asi_eligibilite(Variable): set_input = set_input_dispatch_by_period def formula(individu, period): - last_month = period.start.period('month').offset(-1) + last_month = Period(('month', period.start, 1)).offset(-1) non_eligible_aspa = not_(individu('aspa_eligibilite', period)) touche_pension_invalidite = individu('pensions_invalidite', period) > 0 diff --git a/openfisca_france/model/prestations/minima_sociaux/ass.py b/openfisca_france/model/prestations/minima_sociaux/ass.py index 78201cc4b5..faa8b74ae1 100644 --- a/openfisca_france/model/prestations/minima_sociaux/ass.py +++ b/openfisca_france/model/prestations/minima_sociaux/ass.py @@ -1,5 +1,7 @@ from numpy import absolute as abs_, logical_and as and_ +from openfisca_core.periods import Period + from openfisca_france.model.base import * @@ -79,7 +81,7 @@ class ass_base_ressources_individu(Variable): def formula(individu, period, parameters): # Rolling year - previous_year = period.start.period('year').offset(-1) + previous_year = Period(('year', period.start, 1)).offset(-1) # N-1 last_year = period.last_year @@ -130,9 +132,9 @@ class ass_base_ressources_conjoint(Variable): def formula(individu, period, parameters): # Rolling year - previous_year = period.start.period('year').offset(-1) + previous_year = Period(('year', period.start, 1)).offset(-1) - last_month = period.start.period('month').offset(-1) + last_month = Period(('month', period.start, 1)).offset(-1) ass_base_ressources_individu = individu('ass_base_ressources_individu', period) chomage_net_interrompue = individu('chomage_net', last_month) == 0 @@ -147,14 +149,14 @@ def formula(individu, period, parameters): def calculateWithAbatement(individu, parameters, period, ressourceName): - last_month = period.start.period('month').offset(-1) + last_month = Period(('month', period.start, 1)).offset(-1) has_ressources_substitution = ( individu('chomage_net', last_month) + individu('indemnites_journalieres', last_month) + individu('retraite_nette', last_month) ) > 0 # Rolling year - previous_year = period.start.period('year').offset(-1) + previous_year = Period(('year', period.start, 1)).offset(-1) ressource_year = individu(ressourceName, previous_year, options=[ADD]) ressource_last_month = individu(ressourceName, last_month) diff --git a/openfisca_france/model/prestations/minima_sociaux/cs/eligibilite.py b/openfisca_france/model/prestations/minima_sociaux/cs/eligibilite.py index 4875139548..6903afb120 100644 --- a/openfisca_france/model/prestations/minima_sociaux/cs/eligibilite.py +++ b/openfisca_france/model/prestations/minima_sociaux/cs/eligibilite.py @@ -1,4 +1,7 @@ from numpy import logical_not as not_ + +from openfisca_core.periods import Period + from openfisca_france.model.base import Variable, Famille, MONTH, ADD, set_input_dispatch_by_period @@ -10,7 +13,7 @@ class css_cmu_acs_eligibilite(Variable): set_input = set_input_dispatch_by_period def formula(famille, period, parameters): - previous_year = period.start.period('year').offset(-1) + previous_year = Period(('year', period.start, 1)).offset(-1) this_year = period.this_year age_min = parameters(period).prestations_sociales.solidarite_insertion.minima_sociaux.cs.cmu.age_limite_pac nb_enfants = famille('cmu_nb_pac', period) diff --git a/openfisca_france/model/prestations/minima_sociaux/cs/ressources.py b/openfisca_france/model/prestations/minima_sociaux/cs/ressources.py index cb50472c65..6699e6ead0 100644 --- a/openfisca_france/model/prestations/minima_sociaux/cs/ressources.py +++ b/openfisca_france/model/prestations/minima_sociaux/cs/ressources.py @@ -1,5 +1,7 @@ from numpy import absolute as abs_, logical_or as or_, logical_not as not_ +from openfisca_core.periods import Period + from openfisca_france.model.base import ( Variable, Individu, @@ -29,7 +31,7 @@ class css_cmu_base_ressources_individu(Variable): def formula(individu, period, parameters): # Rolling year - previous_year = period.start.period('year').offset(-1) + previous_year = Period(('year', period.start, 1)).offset(-1) # N-1 last_year = period.last_year last_month = period.last_month @@ -93,7 +95,7 @@ class css_cmu_base_ressources(Variable): set_input = set_input_divide_by_period def formula(famille, period, parameters): - previous_year = period.start.period('year').offset(-1) + previous_year = Period(('year', period.start, 1)).offset(-1) ressources_famille_a_inclure = [ 'af', diff --git a/openfisca_france/model/prestations/minima_sociaux/rsa.py b/openfisca_france/model/prestations/minima_sociaux/rsa.py index b7d6dce308..ca961476db 100644 --- a/openfisca_france/model/prestations/minima_sociaux/rsa.py +++ b/openfisca_france/model/prestations/minima_sociaux/rsa.py @@ -1,6 +1,8 @@ from numpy import datetime64, logical_and as and_, logical_or as or_ from openfisca_core import periods +from openfisca_core.periods import Period + from openfisca_france.model.base import * from openfisca_france.model.prestations.prestations_familiales.base_ressource import nb_enf @@ -939,7 +941,7 @@ class rsa_non_calculable_tns_individu(Variable): # En fait l'évaluation par le PCD est plutôt l'exception que la règle. En général on retient plutôt le bénéfice déclaré au FISC (après abattement forfaitaire ou réel). def formula(individu, period): - this_year_and_last_year = period.start.offset('first-of', 'year').period('year', 2).offset(-1) + this_year_and_last_year = Period(('year', period.start.offset('first-of', 'year'), 2)).offset(-1) rpns_benefice_exploitant_agricole = individu('rpns_benefice_exploitant_agricole', this_year_and_last_year, options = [ADD]) rpns_micro_entreprise_chiffre_affaires = individu('rpns_micro_entreprise_chiffre_affaires', this_year_and_last_year, options = [ADD]) rpns_autres_revenus = individu('rpns_autres_revenus', this_year_and_last_year, options = [ADD]) diff --git a/openfisca_france/model/prestations/prestations_familiales/ars.py b/openfisca_france/model/prestations/prestations_familiales/ars.py index 27552b7a6a..4cd2943b70 100644 --- a/openfisca_france/model/prestations/prestations_familiales/ars.py +++ b/openfisca_france/model/prestations/prestations_familiales/ars.py @@ -1,4 +1,7 @@ from numpy import logical_not as not_ + +from openfisca_core.periods import Period + from openfisca_france.model.base import * from openfisca_france.model.prestations.prestations_familiales.base_ressource import nb_enf @@ -15,8 +18,8 @@ def formula(famille, period, parameters): Allocation de rentrée scolaire brute de CRDS ''' janvier = period.first_month - octobre = period.start.offset('first-of', 'year').offset(9, 'month').period('month') - decembre = period.start.offset('first-of', 'year').offset(11, 'month').period('month') + octobre = Period(('month', period.start.offset('first-of', 'year').offset(9, 'month'), 1)) + decembre = Period(('month', period.start.offset('first-of', 'year').offset(11, 'month'), 1)) af_nbenf = famille('af_nbenf', octobre) base_ressources = famille('prestations_familiales_base_ressources', janvier) ars = parameters(octobre).prestations_sociales.prestations_familiales.education_presence_parentale.ars diff --git a/openfisca_france/model/prestations/prestations_familiales/base_ressource.py b/openfisca_france/model/prestations/prestations_familiales/base_ressource.py index 63527b5871..3722dcea4b 100644 --- a/openfisca_france/model/prestations/prestations_familiales/base_ressource.py +++ b/openfisca_france/model/prestations/prestations_familiales/base_ressource.py @@ -1,8 +1,8 @@ -from numpy import logical_or as or_ +from numpy import datetime64, logical_or as or_ -from openfisca_france.model.base import * +from openfisca_core.periods import Period -from numpy import datetime64 +from openfisca_france.model.base import * class autonomie_financiere(Variable): @@ -18,7 +18,7 @@ class autonomie_financiere(Variable): def formula(individu, period, parameters): # D'après service-public.fr, la condition de dépassement du salaire plafonds n'est pas évalué de la même manière suivant si l'enfant est étudiant ou salarié/apprenti/stagiaire. - salaire_net_mensualise = individu('salaire_net', period.start.period('month', 6).offset(-6), options = [ADD]) / 6 + salaire_net_mensualise = individu('salaire_net', Period(('month', period.start, 6)).offset(-6), options = [ADD]) / 6 _P = parameters(period) diff --git a/openfisca_france/model/revenus/activite/non_salarie.py b/openfisca_france/model/revenus/activite/non_salarie.py index 9814f81123..f1d6696863 100644 --- a/openfisca_france/model/revenus/activite/non_salarie.py +++ b/openfisca_france/model/revenus/activite/non_salarie.py @@ -1,3 +1,5 @@ +from openfisca_core.periods import Period + from openfisca_france.model.base import * @@ -2085,7 +2087,7 @@ class travailleur_non_salarie(Variable): set_input = set_input_dispatch_by_period def formula(individu, period, parameters): - this_year_and_last_year = period.start.offset('first-of', 'year').period('year', 2).offset(-1) + this_year_and_last_year = Period(('year', period.start.offset('first-of', 'year'), 2)).offset(-1) rpns_auto_entrepreneur_chiffre_affaires = individu('rpns_auto_entrepreneur_chiffre_affaires', period) != 0 rpns_micro_entreprise_chiffre_affaires = individu('rpns_micro_entreprise_chiffre_affaires', this_year_and_last_year, options = [ADD]) != 0 rpns_autres_revenus = individu('rpns_autres_revenus', this_year_and_last_year, options = [ADD]) != 0 diff --git a/openfisca_france/model/revenus/activite/salarie.py b/openfisca_france/model/revenus/activite/salarie.py index f7ad8ea6d7..3a7d5f8cf0 100644 --- a/openfisca_france/model/revenus/activite/salarie.py +++ b/openfisca_france/model/revenus/activite/salarie.py @@ -1,5 +1,8 @@ from functools import partial from numpy import busday_count as original_busday_count, datetime64, timedelta64, where + +from openfisca_core.periods import Period + from openfisca_france.model.base import * @@ -717,7 +720,7 @@ class ppv_eligibilite_exceptionnelle(Variable): ''' def formula_2022_07_01(individu, period, parameters): - annee_glissante = period.start.period('year').offset(-1) + annee_glissante = Period(('year', period.start, 1)).offset(-1) salaire_de_base_annuel = individu('salaire_de_base', annee_glissante, options=[ADD]) smic_b_annuel = parameters(period).marche_travail.salaire_minimum.smic.smic_b_mensuel * 12 quotite_de_travail = individu('quotite_de_travail', period, options=[ADD]) / 12 @@ -814,7 +817,7 @@ def formula_2019_01_01(individu, period, parameters): sinon Pas d'exonération ''' - annee_glissante = period.start.period('year').offset(-1) + annee_glissante = Period(('year', period.start, 1)).offset(-1) salaire_de_base_annuel = individu('salaire_de_base', annee_glissante, options=[ADD]) smic_b_annuel = parameters(period).marche_travail.salaire_minimum.smic.smic_b_mensuel * 12 quotite_de_travail = individu('quotite_de_travail', period, options=[ADD]) / 12 @@ -1246,7 +1249,7 @@ class indice_majore(Variable): set_input = set_input_dispatch_by_period def formula(individu, period, parameters): - period = period.start.period('month').offset('first-of') + period = Period(('month', period.start, 1)).offset('first-of') categorie_salarie = individu('categorie_salarie', period) traitement_indiciaire_brut = individu('traitement_indiciaire_brut', period) traitement_annuel_brut = parameters(period).prestations_sociales.fonc.IM_100 @@ -1297,7 +1300,7 @@ def formula(famille, period, parameters): D'où l'introduction de cette variable alternative. ''' - salaire_de_base_mensualise = famille.members('salaire_de_base', period.start.period('month', 6).offset(-6), options = [ADD]) + salaire_de_base_mensualise = famille.members('salaire_de_base', Period(('month', period.start, 6)).offset(-6), options = [ADD]) law = parameters(period) nbh_travaillees = 169 smic_mensuel_brut = law.marche_travail.salaire_minimum.smic.smic_b_horaire * nbh_travaillees diff --git a/openfisca_france/model/revenus/remplacement/rente_accident_travail.py b/openfisca_france/model/revenus/remplacement/rente_accident_travail.py index 580d9163d3..8768295662 100644 --- a/openfisca_france/model/revenus/remplacement/rente_accident_travail.py +++ b/openfisca_france/model/revenus/remplacement/rente_accident_travail.py @@ -1,3 +1,5 @@ +from openfisca_core.periods import Period + from openfisca_france.model.base import * @@ -10,7 +12,7 @@ class rente_accident_travail(Variable): set_input = set_input_divide_by_period def formula(individu, period): - previous_year = period.start.period('year').offset(-1) + previous_year = Period(('year', period.start, 1)).offset(-1) non_salarie_agricole = individu('rpns_benefice_exploitant_agricole', previous_year, options=[ADD]) != 0 rente_accident_travail_salarie = individu('rente_accident_travail_salarie', period) rente_accident_travail_exploitant_agricole = individu('rente_accident_travail_exploitant_agricole', period) @@ -27,7 +29,7 @@ class rente_accident_travail_salarie(Variable): set_input = set_input_divide_by_period def formula(individu, period): - previous_year = period.start.period('year').offset(-1) + previous_year = Period(('year', period.start, 1)).offset(-1) salarie = individu('salaire_net', previous_year, options=[ADD]) != 0 rente_accident_travail_rachat = individu('rente_accident_travail_rachat', period) taux_incapacite = individu('taux_accident_travail', period) @@ -52,7 +54,7 @@ class rente_accident_travail_exploitant_agricole(Variable): set_input = set_input_divide_by_period def formula(individu, period): - previous_year = period.start.period('year').offset(-1) + previous_year = Period(('year', period.start, 1)).offset(-1) non_salarie_agricole = individu('rpns_benefice_exploitant_agricole', previous_year, options=[ADD]) != 0 rente_accident_travail_rachat = individu('rente_accident_travail_rachat', period) taux_incapacite = individu('taux_accident_travail', period) @@ -180,7 +182,7 @@ class rente_accident_travail_salaire_utile(Variable): set_input = set_input_divide_by_period def formula(individu, period, parameters): - previous_year = period.start.period('year').offset(-1) + previous_year = Period(('year', period.start, 1)).offset(-1) rente_at = parameters(period).prestations_sociales.solidarite_insertion.minima_sociaux.accident_travail.rente salaire_net = individu('salaire_net', previous_year, options=[ADD])