Retour sur les résumé

pull/2081/head
Jérémy Rialland 2022-03-30 15:28:01 +02:00 committed by Johan Girod
parent c0e35fcda1
commit cb40c54296
3 changed files with 197 additions and 98 deletions

View File

@ -518,11 +518,11 @@ code . début d'activité:
code . LFSS:
variations:
- si: LFSS 300 + LFSS 600 = 0€
alors: "'N'"
- si: secteur . S2
alors:
texte: O;{{ mois S2 }}
- si: LFSS 300 + LFSS 600 = 0€
alors: "'N'"
- si: LFSS 300 = 0€
alors:
texte: O;{{ mois 600 }}

View File

@ -7,9 +7,13 @@ import { Li, Ul } from '@/design-system/typography/list'
import { Body } from '@/design-system/typography/paragraphs'
import { Grid } from '@mui/material'
import { DottedName as ExoCovidDottedNames } from 'exoneration-covid'
import Engine, { EvaluatedNode, PublicodesExpression } from 'publicodes'
import Engine, {
EvaluatedNode,
Evaluation,
PublicodesExpression,
} from 'publicodes'
import { Key, useRef } from 'react'
import { Trans } from 'react-i18next'
import { Trans, useTranslation } from 'react-i18next'
import { useExoCovidEngine, useExoCovidSituationState } from '.'
import { Bold, GridTotal, Italic, Recap, RecapExpert, Total } from './Recap'
import { Row, Table, Tbody, Th, Thead, Tr } from './Table'
@ -60,6 +64,7 @@ interface Props {
export const FormulaireS1S1Bis = ({ onChange }: Props) => {
const engine = useExoCovidEngine()
const { t } = useTranslation()
const { situation = {} } = useExoCovidSituationState()
const selectedKey = useRef<{ [key: string]: Key | undefined }>({})
@ -74,6 +79,12 @@ export const FormulaireS1S1Bis = ({ onChange }: Props) => {
name.match(/^mois \. [^.]*$/)
)
const formatZeroToEmpty = (str?: string) =>
typeof str === 'undefined' || str === '0' ? t('vide') : str
const formatYesNo = (str?: string | null) =>
str?.startsWith('O') ? t('oui') : t('non')
let isAnyRowShowed = false
return (
@ -324,65 +335,106 @@ export const FormulaireS1S1Bis = ({ onChange }: Props) => {
</Li>
<Li>
Nombres de mois pour lesquels vous remplissez les conditions
d'éligibilité
<Ul>
<Li>
LFSS :{' '}
<Bold as="span">
<Value
engine={engine}
expression="LFSS . mois éligibles"
linkToRule={false}
precision={0}
/>
</Bold>{' '}
(
<Bold as="span">
{engine.evaluate('code . LFSS').nodeValue}
</Bold>
)
<Ul>
<Li>
dont LFSS 600{' '}
<Bold as="span">
<Value
engine={engine}
expression="LFSS 600 . mois éligibles"
linkToRule={false}
precision={0}
/>
</Bold>{' '}
et LFSS 300{' '}
<Bold as="span">
<Value
engine={engine}
expression="LFSS 300 . mois éligibles"
linkToRule={false}
precision={0}
/>
</Bold>
</Li>
</Ul>
</Li>
Eligibilité LFSS :{' '}
<Bold as="span">
{formatYesNo(
engine.evaluate('code . LFSS')
.nodeValue as Evaluation<string>
)}
</Bold>{' '}
(
<Bold as="span">
{
engine
.evaluate('code . LFSS')
.nodeValue?.toString()
.split(';')[0]
}
</Bold>
)
</Li>
<Li>
LFR1 :{' '}
<Bold as="span">
<Value
engine={engine}
expression="LFR1 . mois éligibles"
linkToRule={false}
precision={0}
/>
</Bold>{' '}
<Li>
Eligibilité LFR :{' '}
<Bold as="span">
{formatYesNo(
engine.evaluate('code . LFR1')
.nodeValue as Evaluation<string>
)}
</Bold>{' '}
(
<Bold as="span">
{
(
<Bold as="span">
{engine.evaluate('code . LFR1').nodeValue}
</Bold>
)
</Li>
</Ul>
engine.evaluate('code . LFR1')
.nodeValue as Evaluation<string>
)?.split(';')[0]
}
</Bold>
)
</Li>
<Li>
Nombre de mois LFSS 600 :{' '}
<Bold as="span">
<Value
engine={engine}
expression="LFSS 600 . mois éligibles"
linkToRule={false}
precision={0}
/>
</Bold>{' '}
(
<Bold as="span">
{formatZeroToEmpty(
engine
.evaluate('LFSS 600 . mois éligibles')
.nodeValue?.toString()
)}
</Bold>
)
</Li>
<Li>
Nombre de mois LFSS 300 :{' '}
<Bold as="span">
<Value
engine={engine}
expression="LFSS 300 . mois éligibles"
linkToRule={false}
precision={0}
/>
</Bold>{' '}
(
<Bold as="span">
{formatZeroToEmpty(
engine
.evaluate('LFSS 300 . mois éligibles')
.nodeValue?.toString()
)}
</Bold>
)
</Li>
<Li>
Nombre de mois LFR :{' '}
<Bold as="span">
<Value
engine={engine}
expression="LFR1 . mois éligibles"
linkToRule={false}
precision={0}
/>
</Bold>{' '}
(
<Bold as="span">
{formatZeroToEmpty(
engine
.evaluate('LFR1 . mois éligibles')
.nodeValue?.toString()
)}
</Bold>
)
</Li>
</RecapExpert>
</Grid>

View File

@ -2,7 +2,7 @@ import Value from '@/components/EngineValue'
import { Radio, ToggleGroup } from '@/design-system/field'
import { Spacing } from '@/design-system/layout'
import { H3 } from '@/design-system/typography/heading'
import { Li, Ul } from '@/design-system/typography/list'
import { Li } from '@/design-system/typography/list'
import { Body } from '@/design-system/typography/paragraphs'
import { Grid } from '@mui/material'
import { DottedName as ExoCovidDottedNames } from 'exoneration-covid'
@ -67,6 +67,12 @@ export const FormulaireS2 = ({
(engine.evaluate('exonération S2 . mois éligibles . plafond')
.nodeValue as Evaluation<number>) ?? 0
const formatZeroToEmpty = (str?: string) =>
typeof str === 'undefined' || str === '0' ? t('vide') : str
const formatYesNo = (str?: string | null) =>
str?.startsWith('O') ? t('oui') : t('non')
return (
<>
{exoS2Applicable ? (
@ -240,43 +246,84 @@ export const FormulaireS2 = ({
</Li>
<Li>
Nombres de mois pour lesquels vous remplissez les conditions
d'éligibilité :{' '}
<Ul>
<Li>
LFSS :{' '}
<Bold as="span">
<Value
engine={engine}
expression="exonération S2 . mois éligibles"
linkToRule={false}
precision={0}
/>
</Bold>{' '}
(
<Bold as="span">
{engine.evaluate('code . LFSS').nodeValue}
</Bold>
)
</Li>
Eligibilité LFSS :{' '}
<Bold as="span">
{formatYesNo(
engine.evaluate('code . LFSS')
.nodeValue as Evaluation<string>
)}
</Bold>{' '}
(
<Bold as="span">
{
engine
.evaluate('code . LFSS')
.nodeValue?.toString()
.split(';')[0]
}
</Bold>
)
</Li>
<Li>
LFR1 :{' '}
<Bold as="span">
<Value
engine={engine}
expression="LFR1 . mois éligibles"
linkToRule={false}
precision={0}
/>
</Bold>{' '}
(
<Bold as="span">
{engine.evaluate('code . LFR1').nodeValue}
</Bold>
)
</Li>
</Ul>
<Li>
Eligibilité LFR :{' '}
<Bold as="span">
{formatYesNo(
engine.evaluate('code . LFR1').nodeValue?.toString()
)}
</Bold>{' '}
(
<Bold as="span">
{engine.evaluate('code . LFR1').nodeValue}
</Bold>
)
</Li>
<Li>
Nombre de mois LFSS 600 :{' '}
<Bold as="span">
<Value
engine={engine}
expression="exonération S2 . mois éligibles"
linkToRule={false}
precision={0}
/>
</Bold>{' '}
(
<Bold as="span">
{formatZeroToEmpty(
engine
.evaluate('exonération S2 . mois éligibles')
.nodeValue?.toString()
)}
</Bold>
)
</Li>
<Li>
Nombre de mois LFSS 300 :{' '}
<Bold as="span">0 mois ({t('vide')})</Bold>
</Li>
<Li>
Nombre de mois LFR :{' '}
<Bold as="span">
<Value
engine={engine}
expression="LFR1 . mois éligibles"
linkToRule={false}
precision={0}
/>
</Bold>{' '}
(
<Bold as="span">
{formatZeroToEmpty(
engine
.evaluate('LFR1 . mois éligibles')
.nodeValue?.toString()
)}
</Bold>
)
</Li>
</RecapExpert>
</Grid>