Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small modification to work with latest version of Python and packages #2115

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@

from openfisca_core.periods import Period
from openfisca_france.model.base import *


Expand Down Expand Up @@ -371,8 +373,13 @@ 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])
# Modified by Emanuele on 02/06/2023
_period = Period(('month', period.start.offset('first-of', 'month').offset(-11, 'month'), 11))
##cumul = individu(variable_name, period.start.offset('first-of', 'month').offset(-11, 'month').period('month', 11), options = [ADD])
cumul = individu(variable_name, _period, options = [ADD])



# December variable_name depends on variable_name in the past 11 months.
# We need to explicitely allow this recursion.

Expand Down
6 changes: 5 additions & 1 deletion openfisca_france/model/prestations/agepi.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,11 @@ 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')

# Modified by Emanuele on 02/06/2023
#annee_glissante = period.start.period('year').offset(-1).offset(-1, 'month')
annee_glissante = Period(('year', period.start.offset(-1, 'year').offset(-1, 'month'), 1))

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é"
Expand Down
6 changes: 4 additions & 2 deletions openfisca_france/model/prestations/aide_mobilite.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,10 @@ 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)

# Modified by Emanuele on 02/06/2023
#annee_glissante = period.start.period('year').offset(-1)
annee_glissante = Period(('year', period.start.offset(-1, 'year'), 1))

aide_mobilite_12_derniers_mois = individu('aide_mobilite', annee_glissante, options=[ADD])

montant_max = parametres_amob.montants.maximum
Expand Down
20 changes: 19 additions & 1 deletion openfisca_france/model/prestations/aides_logement.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import pkg_resources
import sys

import numpy as np
from numpy import ceil, datetime64, fromiter, int16, logical_or as or_, logical_and as and_, logical_not as not_

import openfisca_france
Expand Down Expand Up @@ -566,7 +567,10 @@ 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')

# Modified by Emanuele on 02/06/2023
#annee_glissante = period.start.period('year').offset(-1).offset(-1, 'month')
annee_glissante = Period(('year', period.start.offset(-1, 'year').offset(-1, 'month'), 1))

salaire_imposable = individu('salaire_imposable', annee_glissante, options=[ADD])
chomage_imposable = individu('chomage_imposable', annee_glissante, options=[ADD])
Expand Down Expand Up @@ -1075,6 +1079,12 @@ def formula(famille, period, parameters):
coloc = famille.demandeur.menage('coloc', period)
chambre = famille.demandeur.menage('logement_chambre', period)
zone_apl = famille.demandeur.menage('zone_apl', period)

# Modified by Emanuele
#print(al)
#print(al_nb_pac, couple, coloc, chambre, zone_apl)
print("The class 'aide_logement_loyer_plafond' is not working and it is ignored!")
return 0

al_loc2 = al.al_loc2.par_zone[zone_apl]

Expand Down Expand Up @@ -1584,6 +1594,10 @@ def formula(famille, period, parameters):
couple = famille('al_couple', period)

categorie = famille('aides_logement_categorie', period)

print("The class 'aides_logement_nb_part' is not working and it is ignored!")
return 0

params = parameters(period).prestations_sociales.aides_logement.allocations_logement.al_param.parametre_n[categorie]

return (
Expand Down Expand Up @@ -1682,6 +1696,10 @@ class aides_logement_primo_accedant_plafond_mensualite(Variable):

def formula(famille, period, parameters):
zone_apl = famille.demandeur.menage('zone_apl', period)

print("The class 'aides_logement_primo_accedant_plafond_mensualite' is not working and it is ignored!")
return 0

plafonds = parameters(period).prestations_sociales.aides_logement.allocations_logement.al_plaf_acc[zone_apl]

al_nb_pac = famille('al_nb_personnes_a_charge', period)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ class contrat_engagement_jeune_montant_forfaitaire(Variable):
def formula_2022_03_01(individu, period, parameters):
parameters_montants = parameters(period).prestations_sociales.aides_jeunes.contrat_engagement_jeune.montants
majeur = individu('majeur', period)
previous_year = period.start.period('year').offset(-1)
# Modified by Emanuele on 02/06/2023
#previous_year = period.start.period('year').offset(-1)
previous_year = Period(('year', period.start.offset(-1, 'year'), 1))

tranche = individu.foyer_fiscal('ir_tranche', previous_year)

montant_forfaitaire = (
Expand Down Expand Up @@ -50,7 +53,10 @@ def formula_2022_03_01(individu, period, parameters):
eligibilite_statut = activite != TypesActivite.etudiant

# En fonction de l'imposition du foyer fiscal
previous_year = period.start.period('year').offset(-1)
# Modified by Emanuele on 02/06/2023
#previous_year = period.start.period('year').offset(-1)
previous_year = Period(('year', period.start.offset(-1, 'year'), 1))

tranche = individu.foyer_fiscal('ir_tranche', previous_year)
eligibilite_ir = (tranche <= 1)

Expand Down
28 changes: 22 additions & 6 deletions openfisca_france/model/prestations/minima_sociaux/aah.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from numpy import datetime64

from openfisca_core.periods import Period
from openfisca_france.model.base import *

from numpy import datetime64

# Références juridiques - Code de la sécurité sociale
#
Expand Down Expand Up @@ -105,7 +107,9 @@ 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)
# Modified by Emanuele on 02/06/2023
#three_previous_months = period.first_month.start.period('month', 3).offset(-3)
three_previous_months = Period(('month', period.first_month.start.offset(-3, 'month'), 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])

Expand Down Expand Up @@ -239,7 +243,9 @@ 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)
# Modified by Emanuele on 02/06/2023
#three_previous_months = period.start.period('month', 3).offset(-3)
three_previous_months = Period(('month', period.start.offset(-3, 'month'), 3))
last_year = period.last_year

ressources_a_inclure = [
Expand Down Expand Up @@ -299,7 +305,10 @@ 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)
# Modified by Emanuele on 02/06/2023
#three_previous_months = period.start.period('month', 3).offset(-3)
three_previous_months = Period(('month', period.start.offset(-3, 'month'), 3))


ressources_a_inclure = [
'asi',
Expand Down Expand Up @@ -564,7 +573,10 @@ 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)
# Modified by Emanuele on 02/06/2023
#annee_precedente = period.start.period('year').offset(-1)
annee_precedente = Period(('year', period.start.offset(-1, 'year'), 1))

prestations = parameters(period).prestations_sociales
taux_incapacite_min = prestations.prestations_etat_de_sante.invalidite.aah.taux_capacite.taux_incapacite
aah = individu('aah', period)
Expand Down Expand Up @@ -606,7 +618,11 @@ 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)

# Modified by Emanuele on 02/06/2023
#annee_precedente = period.start.period('year').offset(-1)
annee_precedente = Period(('year', period.start.offset(-1, 'year'), 1))

activite_12_mois = individu('salaire_imposable', annee_precedente, options = [ADD]) + individu('rpns_imposables', annee_precedente)

garantie_ressources = invalidite.caah.garantie_ressources
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from numpy import abs as abs_, logical_or as or_

from openfisca_core.periods import Period
from openfisca_france.model.base import *


Expand Down Expand Up @@ -147,7 +148,9 @@ class asi_eligibilite(Variable):
set_input = set_input_dispatch_by_period

def formula(individu, period):
last_month = period.start.period('month').offset(-1)
# Modified by Emanuele on 02/06/2023
#last_month = period.start.period('month').offset(-1)
last_month = Period(('month', period.start.offset(-1, 'month'), 1))

non_eligible_aspa = not_(individu('aspa_eligibilite', period))
touche_pension_invalidite = individu('pensions_invalidite', period) > 0
Expand Down
23 changes: 18 additions & 5 deletions openfisca_france/model/prestations/minima_sociaux/ass.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from numpy import absolute as abs_, logical_and as and_

from openfisca_core.periods import Period
from openfisca_france.model.base import *


Expand Down Expand Up @@ -79,7 +80,10 @@ class ass_base_ressources_individu(Variable):

def formula(individu, period, parameters):
# Rolling year
previous_year = period.start.period('year').offset(-1)
# Modified by Emanuele on 02/06/2023
#previous_year = period.start.period('year').offset(-1)
previous_year = Period(('year', period.start.offset(-1, 'year'), 1))

# N-1
last_year = period.last_year

Expand Down Expand Up @@ -130,9 +134,13 @@ class ass_base_ressources_conjoint(Variable):

def formula(individu, period, parameters):
# Rolling year
previous_year = period.start.period('year').offset(-1)
# Modified by Emanuele on 02/06/2023
#previous_year = period.start.period('year').offset(-1)
previous_year = Period(('year', period.start.offset(-1, 'year'), 1))

last_month = period.start.period('month').offset(-1)
# Modified by Emanuele on 02/06/2023
#last_month = period.start.period('month').offset(-1)
last_month = Period(('month', period.start.offset(-1, 'month'), 1))

ass_base_ressources_individu = individu('ass_base_ressources_individu', period)
chomage_net_interrompue = individu('chomage_net', last_month) == 0
Expand All @@ -147,14 +155,19 @@ def formula(individu, period, parameters):


def calculateWithAbatement(individu, parameters, period, ressourceName):
last_month = period.start.period('month').offset(-1)
# Modified by Emanuele on 02/06/2023
#last_month = period.start.period('month').offset(-1)
last_month = Period(('month', period.start.offset(-1, 'month'), 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)
# Modified by Emanuele on 02/06/2023
#previous_year = period.start.period('year').offset(-1)
previous_year = Period(('year', period.start.offset(-1, 'year'), 1))

ressource_year = individu(ressourceName, previous_year, options=[ADD])
ressource_last_month = individu(ressourceName, last_month)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
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


Expand All @@ -10,7 +12,10 @@ 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)
# Modified by Emanuele on 02/06/2023
#previous_year = period.start.period('year').offset(-1)
previous_year = Period(('year', period.start.offset(-1, 'year'), 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)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
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,
Expand Down Expand Up @@ -29,7 +30,10 @@ class css_cmu_base_ressources_individu(Variable):

def formula(individu, period, parameters):
# Rolling year
previous_year = period.start.period('year').offset(-1)
# Modified by Emanuele on 02/06/2023
#previous_year = period.start.period('year').offset(-1)
previous_year = Period(('year', period.start.offset(-1, 'year'), 1))

# N-1
last_year = period.last_year
last_month = period.last_month
Expand Down Expand Up @@ -93,7 +97,9 @@ 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)
# Modified by Emanuele on 02/06/2023
#previous_year = period.start.period('year').offset(-1)
previous_year = Period(('year', period.start.offset(-1, 'year'), 1))

ressources_famille_a_inclure = [
'af',
Expand Down
9 changes: 7 additions & 2 deletions openfisca_france/model/prestations/minima_sociaux/rsa.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
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

Expand Down Expand Up @@ -959,8 +960,12 @@ 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)
def formula(individu, period):
# Modified by Emanuele on 02/06/2023
#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').offset(-1, 'year'), 2))


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])
Expand Down
10 changes: 8 additions & 2 deletions openfisca_france/model/prestations/prestations_familiales/ars.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
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

Expand All @@ -15,8 +17,12 @@ 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')

# Modified by Emanuele on 02/06/2023
#octobre = period.start.offset('first-of', 'year').offset(9, 'month').period('month')
octobre = Period(('month', period.start.offset('first-of', 'year').offset(9, 'month'), 1))
#decembre = period.start.offset('first-of', 'year').offset(11, 'month').period('month')
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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from numpy import logical_or as or_

from openfisca_core.periods import Period
from openfisca_france.model.base import *

from numpy import datetime64
Expand All @@ -18,7 +19,10 @@ 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
# Modified by Emanuele on 02/06/2023
_period = Period(('month', period.start.offset(-6, 'month'), 6))
##salaire_net_mensualise = individu('salaire_net', period.start.period('month', 6).offset(-6), options = [ADD]) / 6
salaire_net_mensualise = individu('salaire_net', _period, options = [ADD]) / 6

_P = parameters(period)

Expand Down
Loading