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

Feat(Lodeom): Ajout de la sélection de zone #3269

Draft
wants to merge 4 commits into
base: feat/2909-3-bareme-switch
Choose a base branch
from
Draft
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
2 changes: 1 addition & 1 deletion modele-social/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ Exporte les règles au format json pour optimiser le chargement

Corrige des bugs dans l’implémentation de la convention collective du sport :

- Enlève la boucle du calcul de la limite d’éxonération de la prévoyance
- Enlève la boucle du calcul de la limite d’exonération de la prévoyance
- Renomme la règle `salarié . convention collective . sport . exonération cotisation AT . refus` en `salarié . convention collective . sport . refus exonération cotisation AT`
- Correction d’unités
- Correction du calcul de la retraite complémenaire AGIRC-ARRCO
Expand Down
4 changes: 3 additions & 1 deletion modele-social/règles/salarié/cotisations.publicodes
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@ salarié . cotisations . exonérations . lodeom . secteurs d'activité éligible
Secteurs d'activité éligibles au Lodeom: https://boss.gouv.fr/portail/accueil/exonerations/exonerations-zonees.html#titre-chapitre-5--exonerations-applica-section-2--conditions-dapplicati-b-conditions-deligibilite-liees-1-secteurs-dactivites-eligibles

salarié . cotisations . exonérations . lodeom . zone un:
titre: Guadeloupe, Martinique, La Réunion, Guyane
titre: Guadeloupe, Guyane, Martinique, La Réunion
non applicable si: zone deux
par défaut: non
une de ces conditions:
- établissement . commune . département = 'Guadeloupe'
Expand Down Expand Up @@ -296,6 +297,7 @@ salarié . cotisations . exonérations . lodeom . zone un:

salarié . cotisations . exonérations . lodeom . zone deux:
titre: Saint-Barthélémy, Saint-Martin
non applicable si: zone un
par défaut: non
une de ces conditions:
- établissement . commune . département = 'Saint-Barthélemy'
Expand Down
55 changes: 44 additions & 11 deletions site/source/components/EffectifSwitch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@
import { useEffect, useState } from 'react'
import { useTranslation } from 'react-i18next'
import { useDispatch } from 'react-redux'
import { styled } from 'styled-components'

import { useEngine } from '@/components/utils/EngineContext'
import { Radio, ToggleGroup } from '@/design-system'
import { FlexCenter } from '@/design-system/global-style'

Check failure on line 9 in site/source/components/EffectifSwitch.tsx

View workflow job for this annotation

GitHub Actions / lint

'FlexCenter' is defined but never used
import { Strong } from '@/design-system/typography'
import { Body } from '@/design-system/typography/paragraphs'
import { enregistreLaRéponse } from '@/store/actions/actions'

export default function EffectifSwitch() {
Expand All @@ -21,16 +25,45 @@
}, [currentEffectif, engineEffectif])

return (
<ToggleGroup
value={currentEffectif}
onChange={(value) => {
setCurrentEffectif(value)
dispatch(enregistreLaRéponse(dottedName, `'${value}'`))
}}
aria-label={t("Effectif de l'entreprise")}
>
<Radio value="10">{t('Moins de 50 salariés')}</Radio>
<Radio value="100">{t('Plus de 50 salariés')}</Radio>
</ToggleGroup>
<Container>
<StyledBody id="effectif-switch-label">
<Strong>{t("Effectif de l'entreprise :")}</Strong>
</StyledBody>
<StyledToggleGroup
value={currentEffectif}
onChange={(value: string) => {
setCurrentEffectif(value)
dispatch(enregistreLaRéponse(dottedName, `'${value}'`))
}}
aria-labelledby="effectif-switch-label"
>
<StyledRadio value="10">{t('Moins de 50 salariés')}</StyledRadio>
<StyledRadio value="100">{t('Plus de 50 salariés')}</StyledRadio>
</StyledToggleGroup>
</Container>
)
}

const Container = styled.div`
text-align: left;
display: flex;
flex-direction: column;
flex-wrap: wrap;
column-gap: ${({ theme }) => theme.spacings.sm};
width: 100%;
`
const StyledBody = styled(Body)`
margin: ${({ theme }) => theme.spacings.xxs} 0;
`
const StyledToggleGroup = styled(ToggleGroup)`
display: flex;
> * {
display: flex;
}
`
const StyledRadio = styled(Radio)`
white-space: nowrap;
> span {
width: 100%;
}
`
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { useTranslation } from 'react-i18next'
import styled from 'styled-components'

Check failure on line 2 in site/source/components/RéductionDeCotisations/RégularisationSwitch.tsx

View workflow job for this annotation

GitHub Actions / lint

'default' import from 'styled-components' is restricted. Please use named import : `import { styled } from "styled-component"` instead

import { Radio, ToggleGroup } from '@/design-system'
import { FlexCenter } from '@/design-system/global-style'

Check failure on line 5 in site/source/components/RéductionDeCotisations/RégularisationSwitch.tsx

View workflow job for this annotation

GitHub Actions / lint

'FlexCenter' is defined but never used
import { Strong } from '@/design-system/typography'
import { Body } from '@/design-system/typography/paragraphs'
import { RégularisationMethod } from '@/utils/réductionDeCotisations'

type Props = {
Expand All @@ -15,28 +19,59 @@
const { t } = useTranslation()

return (
<ToggleGroup
value={régularisationMethod}
onChange={(value) => {
setRégularisationMethod(value as RégularisationMethod)
}}
aria-label={t(
'pages.simulateurs.réduction-générale.régularisation.type',
'Type de régularisation'
)}
>
<Radio value="annuelle">
{t(
'pages.simulateurs.réduction-générale.régularisation.annuelle',
'Régularisation annuelle'
)}
</Radio>
<Radio value="progressive">
{t(
'pages.simulateurs.réduction-générale.régularisation.progressive',
'Régularisation progressive'
)}
</Radio>
</ToggleGroup>
<Container>
<StyledBody id="régularisation-switch-label">
<Strong>
{t(
'pages.simulateurs.réduction-générale.régularisation.type',
'Type de régularisation :'
)}
</Strong>
</StyledBody>
<StyledToggleGroup
value={régularisationMethod}
onChange={(value) => {
setRégularisationMethod(value as RégularisationMethod)
}}
aria-labelledby="régularisation-switch-label"
>
<StyledRadio value="annuelle">
{t(
'pages.simulateurs.réduction-générale.régularisation.annuelle',
'Régularisation annuelle'
)}
</StyledRadio>
<StyledRadio value="progressive">
{t(
'pages.simulateurs.réduction-générale.régularisation.progressive',
'Régularisation progressive'
)}
</StyledRadio>
</StyledToggleGroup>
</Container>
)
}

const Container = styled.div`
text-align: left;
display: flex;
flex-direction: column;
flex-wrap: wrap;
column-gap: ${({ theme }) => theme.spacings.sm};
width: 100%;
`
const StyledBody = styled(Body)`
margin: ${({ theme }) => theme.spacings.xxs} 0;
`
const StyledToggleGroup = styled(ToggleGroup)`
display: flex;
> * {
display: flex;
}
`
const StyledRadio = styled(Radio)`
white-space: nowrap;
> span {
width: 100%;
}
`
51 changes: 0 additions & 51 deletions site/source/hooks/useBaremeLodeom.ts

This file was deleted.

77 changes: 77 additions & 0 deletions site/source/hooks/useBarèmeLodeom.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import { DottedName } from 'modele-social'
import { useDispatch } from 'react-redux'

import { useEngine } from '@/components/utils/EngineContext'
import { toOuiNon } from '@/domaine/engine/toOuiNon'
import {
batchUpdateSituation,
deleteFromSituation,
} from '@/store/actions/actions'

import { useZoneLodeom, ZoneLodeom as Zone } from './useZoneLodeom'

const barèmes = {
['zone un' as Zone]: [
'barème compétitivité',
'barème compétitivité renforcée',
'barème innovation et croissance',
],
['zone deux' as Zone]: [
'barème moins de 11 salariés',
'barème sectoriel',
'barème compétitivité',
],
}

export type Barème = (typeof barèmes)[Zone][number]

type ReturnType = {
barèmes: Barème[]
currentBarème?: Barème
updateBarème: (barème?: Barème) => void
}

export const useBarèmeLodeom = (): ReturnType => {
const dottedName = 'salarié . cotisations . exonérations . lodeom'
const { currentZone } = useZoneLodeom()
const engine = useEngine()
const dispatch = useDispatch()

const barèmesPossibles = currentZone ? barèmes[currentZone] : []

const currentBarème = barèmesPossibles.find((barème) => {
const barèmeValue = engine.evaluate(
`${dottedName} . ${currentZone} . ${barème}`
).nodeValue

return !!barèmeValue
})

const updateBarème = (newBarème?: Barème): void => {
if (!newBarème) {
barèmesPossibles.forEach((barème) => {
dispatch(
deleteFromSituation(
`${dottedName} . ${currentZone} . ${barème}` as DottedName
)
)
})
} else {
const newSituation = barèmesPossibles.reduce((situation, barème) => {
return {
...situation,
[`${dottedName} . ${currentZone} . ${barème}`]: toOuiNon(
barème === newBarème
),
}
}, {})
dispatch(batchUpdateSituation(newSituation))
}
}

return {
barèmes: barèmesPossibles,
currentBarème,
updateBarème,
}
}
38 changes: 38 additions & 0 deletions site/source/hooks/useZoneLodeom.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { useDispatch } from 'react-redux'

import { useEngine } from '@/components/utils/EngineContext'
import { toOuiNon } from '@/domaine/engine/toOuiNon'
import { batchUpdateSituation } from '@/store/actions/actions'

const zones = ['zone un', 'zone deux']

export type ZoneLodeom = (typeof zones)[number]

type ReturnType = {
currentZone?: ZoneLodeom
updateZone: (zone: ZoneLodeom) => void
}

export const useZoneLodeom = (): ReturnType => {
const engine = useEngine()
const dispatch = useDispatch()
const dottedName = 'salarié . cotisations . exonérations . lodeom'

const currentZone = zones.find((zone) => {
const zoneValue = engine.evaluate(`${dottedName} . ${zone}`).nodeValue

return !!zoneValue
})

const updateZone = (newZone: ZoneLodeom): void => {
const newSituation = zones.reduce((situation, zone) => {
return {
...situation,
[`${dottedName} . ${zone}`]: toOuiNon(zone === newZone),
}
}, {})
dispatch(batchUpdateSituation(newSituation))
}

return { currentZone, updateZone }
}
Loading
Loading