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

Maj prelevement forfaitaire liberatoire #2087

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
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
2 changes: 1 addition & 1 deletion .github/test-api.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
PORT=5000
ENDPOINT=spec

openfisca serve --country-package openfisca_france --port $PORT &
openfisca serve --country-package openfisca_france --port $PORT --workers 1 &
server_pid=$!

curl --retry-connrefused --retry 10 --retry-delay 5 --fail http://127.0.0.1:$PORT/$ENDPOINT | python -m json.tool > /dev/null
Expand Down
22 changes: 11 additions & 11 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
fail-fast: true
matrix:
os: ["ubuntu-20.04"] # On peut ajouter "macos-latest" si besoin
python-version: ["3.7.9", "3.8.9", "3.9.9"]
python-version: ["3.9.9", "3.10.6"]
steps:
- name: Checkout
uses: actions/checkout@v2
Expand Down Expand Up @@ -48,7 +48,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.7.9
python-version: 3.9.9
- name: Cache build
id: restore-build
uses: actions/cache@v2
Expand All @@ -68,7 +68,7 @@ jobs:
fail-fast: true
matrix:
os: [ "ubuntu-20.04" ] # On peut ajouter "macos-latest" si besoin
python-version: ["3.7.9", "3.8.9", "3.9.9"]
python-version: ["3.9.9", "3.10.6"]
steps:
- uses: actions/checkout@v2
- name: Set up Python
Expand All @@ -92,7 +92,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.7.9
python-version: 3.9.9
- name: Test max path length
run: make check-path-length

Expand All @@ -112,7 +112,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.7.9
python-version: 3.9.9
- name: Cache build
id: restore-build
uses: actions/cache@v2
Expand All @@ -138,7 +138,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.7.9
python-version: 3.9.9
- name: Cache build
id: restore-build
uses: actions/cache@v2
Expand All @@ -158,7 +158,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.7.9
python-version: 3.9.9
- name: Check version number has been properly updated
run: "${GITHUB_WORKSPACE}/.github/is-version-number-acceptable.sh"

Expand All @@ -178,7 +178,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.7.9
python-version: 3.9.9
- id: stop-early
run: if "${GITHUB_WORKSPACE}/.github/has-functional-changes.sh" ; then echo "::set-output name=status::success" ; fi

Expand All @@ -196,7 +196,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.7.9
python-version: 3.9.9
- name: Cache build
id: restore-build
uses: actions/cache@v2
Expand All @@ -223,7 +223,7 @@ jobs:
- uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
python-version: "3.7.9"
python-version: "3.9.9"
# Add conda-forge for OpenFisca-Core
channels: conda-forge
activate-environment: true
Expand Down Expand Up @@ -284,7 +284,7 @@ jobs:
- uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
python-version: "3.7.9"
python-version: "3.9.9"
# Add conda-forge for OpenFisca-Core
channels: conda-forge
activate-environment: true
Expand Down
4 changes: 4 additions & 0 deletions openfisca_france/model/base.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
from openfisca_core.model_api import *
from openfisca_france.entities import Famille, FoyerFiscal, Individu, Menage # noqa F401


AGE_INT_MINIMUM = -9999


# Enums commonly used through the legislation


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class jour_xyz(Variable):
class age(Variable):
unit = 'years'
value_type = int
default_value = -9999
default_value = AGE_INT_MINIMUM
entity = Individu
label = 'Âge (en années) au premier jour du mois'
definition_period = MONTH
Expand Down Expand Up @@ -81,7 +81,7 @@ def formula(individu, period, parameters):

class age_en_mois(Variable):
value_type = int
default_value = -9999
default_value = AGE_INT_MINIMUM
unit = 'months'
entity = Individu
label = 'Âge (en mois)'
Expand Down Expand Up @@ -2544,7 +2544,7 @@ def abat_rpns(rev, P):
return min_(
f5ht + f5it + f5jt + f5kt + f5lt + f5mt,
abat_rpns(mncn_impo, specialbnc.services) + mncn_pvct + cncn_aimp + (1 + cga) * cncn_bene
) #  TODO check !
) # TODO check !


class defmeu(Variable):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand Down
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 @@ -271,7 +273,7 @@ def iter_cotisations():
# FIXME: dirty fix since public_titulaire_militaire does not exist
if categorie_salarie_type.name == 'public_titulaire_militaire':
continue
raise(e)
raise e

if bareme_name in cotisations_by_categorie_salarie[categorie_salarie_type.name]:
bareme = categorie_salarie_baremes[bareme_name]
Expand Down Expand Up @@ -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.

Expand Down
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 @@ -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)

Expand Down
4 changes: 3 additions & 1 deletion openfisca_france/model/prestations/agepi.py
Original file line number Diff line number Diff line change
@@ -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,\
Expand Down Expand Up @@ -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é"
Expand Down
5 changes: 4 additions & 1 deletion openfisca_france/model/prestations/aide_mobilite.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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])

Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 3 additions & 3 deletions openfisca_france/model/prestations/aides_logement.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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])
Expand Down
10 changes: 6 additions & 4 deletions openfisca_france/model/prestations/autonomie.py
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 @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
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 * # noqa analysis:ignore


Expand All @@ -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
Expand Down Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions openfisca_france/model/prestations/logement_social.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)

Expand Down
Loading