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

CDHR - Contribution différentielle applicable à certains contribuables titulaires de hauts revenus #2444

Merged
merged 21 commits into from
Mar 6, 2025
Merged
40 changes: 19 additions & 21 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ on:
types: [opened, reopened]

env:
DEFAULT_PYTHON_VERSION: '3.10.6'
DEFAULT_PYTHON_VERSION: '3.10.11'

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: ["ubuntu-20.04"] # On peut ajouter "macos-latest" si besoin
python-version: ["3.9.9", "3.10.6"]
os: ["ubuntu-24.04"] # On peut ajouter "macos-latest" si besoin
python-version: ["3.9.12", "3.10.11"]
openfisca-dependencies: [minimal, maximal]
steps:
- name: Checkout
Expand Down Expand Up @@ -63,7 +63,7 @@ jobs:
- name: Build conda package
uses: prefix-dev/[email protected]
with:
build-args: --channel openfisca --channel conda-forge --output-dir ./conda-bld
build-args: --quiet --channel openfisca --channel conda-forge --output-dir ./conda-bld
recipe-path: .conda/recipe.yaml
upload-artifact: false
- name: Setup conda
Expand All @@ -81,10 +81,8 @@ jobs:
shell: pwsh
run: openfisca test tests/formulas/irpp.yaml



lint-files:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
strategy:
matrix:
dependencies-version: [maximal]
Expand All @@ -102,7 +100,7 @@ jobs:
uses: actions/cache@v4
with:
path: ${{ env.pythonLocation }}
key: build-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-${{ github.sha }}-ubuntu-20.04-${{ matrix.dependencies-version }}
key: build-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-${{ github.sha }}-ubuntu-24.04-${{ matrix.dependencies-version }}
- run: make check-syntax-errors
- run: make check-style
- name: Lint Python files
Expand All @@ -116,8 +114,8 @@ jobs:
strategy:
fail-fast: true
matrix:
os: [ "ubuntu-20.04" ] # On peut ajouter "macos-latest" si besoin
python-version: ["3.9.9", "3.10.6"]
os: [ "ubuntu-24.04" ] # On peut ajouter "macos-latest" si besoin
python-version: ["3.9.12", "3.10.11"]
openfisca-dependencies: [minimal, maximal]
steps:
- uses: actions/checkout@v4
Expand All @@ -134,10 +132,10 @@ jobs:
- run: |
shopt -s globstar
openfisca test --country-package openfisca_france tests/**/*.py
if: matrix.openfisca-dependencies != 'minimal' || matrix.python-version != '3.9.9'
if: matrix.openfisca-dependencies != 'minimal' || matrix.python-version != '3.9.12'

test-path-length:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Set up Python
Expand All @@ -148,7 +146,7 @@ jobs:
run: make check-path-length

test-yaml:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
needs: [ build ]
strategy:
fail-fast: false
Expand All @@ -170,7 +168,7 @@ jobs:
uses: actions/cache@v4
with:
path: ${{ env.pythonLocation }}
key: build-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-${{ github.sha }}-ubuntu-20.04-${{ matrix.openfisca-dependencies }}
key: build-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-${{ github.sha }}-ubuntu-24.04-${{ matrix.openfisca-dependencies }}
- name: Split YAML tests
id: yaml-test
env:
Expand All @@ -183,7 +181,7 @@ jobs:
openfisca test --country-package openfisca_france ${TEST_FILES_SUBLIST}

test-api:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
strategy:
matrix:
dependencies-version: [maximal]
Expand All @@ -199,7 +197,7 @@ jobs:
uses: actions/cache@v4
with:
path: ${{ env.pythonLocation }}
key: build-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-${{ github.sha }}-ubuntu-20.04-${{ matrix.dependencies-version }}
key: build-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-${{ github.sha }}-ubuntu-24.04-${{ matrix.dependencies-version }}
- name: Test the Web API
run: "${GITHUB_WORKSPACE}/.github/test-api.sh"

Expand Down Expand Up @@ -234,7 +232,7 @@ jobs:
run: openfisca test tests/formulas/irpp.yaml

check-version-and-changelog:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
needs: [ lint-files, test-python, test-yaml, test-api ] # Last job to run
steps:
- uses: actions/checkout@v4
Expand All @@ -251,7 +249,7 @@ jobs:
# We build a separate job to substitute the halt option.
# The `deploy` job is dependent on the output of the `check-for-functional-changes` job.
check-for-functional-changes:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
if: github.ref == 'refs/heads/master' # Only triggered for the `master` branch
needs: [ check-version-and-changelog ]
outputs:
Expand All @@ -268,7 +266,7 @@ jobs:
run: if "${GITHUB_WORKSPACE}/.github/has-functional-changes.sh" ; then echo "::set-output name=status::success" ; fi

deploy:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
strategy:
matrix:
dependencies-version: [maximal]
Expand All @@ -290,13 +288,13 @@ jobs:
uses: actions/cache@v4
with:
path: ${{ env.pythonLocation }}
key: build-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-${{ github.sha }}-ubuntu-20.04-${{ matrix.dependencies-version }}
key: build-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-${{ github.sha }}-ubuntu-24.04-${{ matrix.dependencies-version }}
- name: Cache release
id: restore-release
uses: actions/cache@v4
with:
path: dist
key: release-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-${{ github.sha }}-ubuntu-20.04-${{ matrix.dependencies-version }}
key: release-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-${{ github.sha }}-ubuntu-24.04-${{ matrix.dependencies-version }}
- name: Upload a Python package to PyPi
run: twine upload dist/* --username $PYPI_USERNAME --password $PYPI_TOKEN
- name: Publish a git tag
Expand Down
13 changes: 12 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Changelog

## 169.18.0 [2444](https://github.com/openfisca/openfisca-france/pull/2444)

* Évolution du système socio-fiscal.
* Périodes concernées : à partir du 01/01/2025.
* Zones impactées :
- `parameters/impot_revenu/contributions_exceptionnelles/contribution_differentielle_hauts_revenus/*`
- `model/prelevements_obligatoires/impot_revenu/contribution_differentielle_hauts_revenus.py`
* Détails :
- Ajout de la [Contribution différentielle applicable à certains contribuables titulaires de hauts revenus (Article 224)](https://www.legifrance.gouv.fr/codes/section_lc/LEGITEXT000006069577/LEGISCTA000051177942/#LEGISCTA000051177942).
- Mise à jour de la CI qui ne fonctionnait plus le 4 mars 2025 en raison de Ubuntu 20.04. Passe à Ubuntu 24.04, ce qui entraine le passage de Python 3.9.9 à 3.9.12 et de 3.10.6 à 3.10.11.
- Documente la façon de debugger les tests YAML.

### 169.17.1 [2449](https://github.com/openfisca/openfisca-france/pull/2449)

* Changement mineur.
Expand All @@ -23,7 +35,6 @@
- Mise à jour des last_value_still_valid_on, des valeurs et des références sur les paramètres qui n'étaient plus à jour et dont la nouvelle valeur a pu être trouvée avec un bon niveau de fiabilité.
- Ajout de l'appel d'un paramètre dans une variable


### 169.16.20 [2459](https://github.com/openfisca/openfisca-france/pull/2459)

* Changement mineur.
Expand Down
31 changes: 31 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,34 @@ Dans ce cas, il peut être pertinent d'exécuter les tests d'OpenFisca-France en

Bien sûr, une fois la version spécifique de core publiée, **ce changement doit être reverté** avant le merge de la pull request sur France.

## Debug des tests YAML avec VS Code

Si vous souhaitez utiliser le debugger de VS Code avec les tests YAML, par exemple pour investiguer la commande suivante :

`openfisca test --country-package openfisca_france tests/impot_revenu/cdhr.yaml`

Il faut créer un fichier de configuration `.vscode/launch.json` avec le contenu suivant :

```json
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Debug current YAML test file",
"type": "debugpy",
"request": "launch",
"program": "${workspaceFolder}/.venv/bin/openfisca",
"args": [
"test",
"--country-package",
"openfisca_france",
"${file}"
],
"console": "integratedTerminal",
"justMyCode": false,
}
]
}
```

Puis dans VS Code, ouvrir le fichier YAML à debugger, et lancer le debugger avec la configuration `Python: Debug current YAML test file` dans l'onglet _Run and Debug_ à gauche.
21 changes: 21 additions & 0 deletions openfisca_france/model/mesures.py
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,27 @@ class impots_directs(Variable):
reference = 'http://fr.wikipedia.org/wiki/Imp%C3%B4t_direct'
definition_period = YEAR

def formula_2025_01_01(menage, period, parameters):
'''
Pour les impôts définis au niveau du foyer fiscal :
on prend en compte l'impôt des foyers fiscaux dont le déclarant principal est dans le ménage
'''

irpp_economique_i = menage.members.foyer_fiscal('irpp_economique', period)
irpp_economique = menage.sum(irpp_economique_i, role = FoyerFiscal.DECLARANT_PRINCIPAL)

isf_ifi_i = menage.members.foyer_fiscal('isf_ifi', period)
isf_ifi = menage.sum(isf_ifi_i, role = FoyerFiscal.DECLARANT_PRINCIPAL)

contribution_differentielle_hauts_revenus_i = menage.members.foyer_fiscal('contribution_differentielle_hauts_revenus', period)
contribution_differentielle_hauts_revenus = menage.sum(contribution_differentielle_hauts_revenus_i, role = FoyerFiscal.DECLARANT_PRINCIPAL)

return (
irpp_economique
+ isf_ifi
+ contribution_differentielle_hauts_revenus
)

def formula(menage, period, parameters):
'''
Pour les impôts définis au niveau du foyer fiscal :
Expand Down
Loading
Loading