Possibilité de préremplir les dates avec le bon exercice

fix #2515
pull/2570/head
Johan Girod 2023-04-20 14:50:29 +02:00
parent bdd09c9021
commit 2e68358e33
5 changed files with 160 additions and 93 deletions

View File

@ -72,79 +72,94 @@ export default function Simulation({
return (
<>
{!firstStepCompleted && <TrackPage name="accueil" />}
<Grid
container
spacing={2}
css={`
justify-content: center;
`}
id={id}
>
<StyledGrid
item
css={`
${fullWidth
? `width: 100%; max-width: none; flex-basis: auto;`
: ''}
`}
xl={9}
lg={10}
md={11}
sm={12}
>
<PrintExportRecover />
{children}
<FromTop>
{(firstStepCompleted || showQuestionsFromBeginning) && (
<>
<div className="print-hidden">
<FromTop>{results}</FromTop>
</div>
<Questions
engines={engines}
customEndMessages={customEndMessages}
/>
</>
)}
<Spacing md />
{!showQuestionsFromBeginning && !firstStepCompleted && (
<PreviousSimulationBanner />
)}
{afterQuestionsSlot}
{existingCompany && (
<Banner icon="✏">
<Trans>
Ce simulateur a été prérempli avec la situation de votre
entreprise.
</Trans>{' '}
<PopoverWithTrigger
trigger={(buttonProps) => (
<Link
{...buttonProps}
aria-haspopup="dialog"
aria-label={t(
'Voir ma situation, accéder à la page de gestion de mon entreprise'
)}
>
<Trans>Voir ma situation</Trans>
</Link>
)}
>
{(close) => <AnswerList onClose={close} />}
</PopoverWithTrigger>
</Banner>
)}
{firstStepCompleted && !hideDetails && (
<>
<ShareOrSaveSimulationBanner share print placeDesEntreprises />
<Spacing lg />
</>
)}
</FromTop>
</StyledGrid>
</Grid>
<SimulationContainer fullWidth={fullWidth} id={id}>
<PrintExportRecover />
{children}
<FromTop>
{(firstStepCompleted || showQuestionsFromBeginning) && (
<>
<div className="print-hidden">
<FromTop>{results}</FromTop>
</div>
<Questions
engines={engines}
customEndMessages={customEndMessages}
/>
</>
)}
<Spacing md />
{!showQuestionsFromBeginning && !firstStepCompleted && (
<PreviousSimulationBanner />
)}
{afterQuestionsSlot}
{existingCompany && (
<Banner icon="✏">
<Trans>
Ce simulateur a été prérempli avec la situation de votre
entreprise.
</Trans>{' '}
<PopoverWithTrigger
trigger={(buttonProps) => (
<Link
{...buttonProps}
aria-haspopup="dialog"
aria-label={t(
'Voir ma situation, accéder à la page de gestion de mon entreprise'
)}
>
<Trans>Voir ma situation</Trans>
</Link>
)}
>
{(close) => <AnswerList onClose={close} />}
</PopoverWithTrigger>
</Banner>
)}
{firstStepCompleted && !hideDetails && (
<>
<ShareOrSaveSimulationBanner share print placeDesEntreprises />
<Spacing lg />
</>
)}
</FromTop>
</SimulationContainer>
{firstStepCompleted && !hideDetails && explanations}
</>
)
}
export function SimulationContainer({
children,
fullWidth = false,
id,
}: {
children: React.ReactNode
fullWidth?: boolean
id?: string
}) {
return (
<Grid
container
spacing={2}
css={`
justify-content: center;
`}
id={id}
>
<StyledGrid
item
css={`
${fullWidth ? `width: 100%; max-width: none; flex-basis: auto;` : ''}
`}
xl={9}
lg={10}
md={11}
sm={12}
>
{children}
</StyledGrid>
</Grid>
)
}

View File

@ -50,7 +50,7 @@ export default function InputSuggestions({
)
}
const StyledInputSuggestion = styled(SmallBody)`
export const StyledInputSuggestion = styled(SmallBody)`
display: flex;
> * {
white-space: nowrap;

View File

@ -955,6 +955,8 @@ gérer:
iframe:
description: Tools for developers
title: Integrate a simulator
impot-société:
préremplir-exercice: Prefill with dates for <2>fiscal year 2022</2> or <6>fiscal year 2023</6>
impotSociété:
warning: "This simulator is aimed at <2>“TPE”</2>: it takes into account the
reduced corporate tax rates."

View File

@ -943,6 +943,9 @@ gérer:
iframe:
description: Outils pour les développeurs
title: Intégrer un simulateur
impot-société:
préremplir-exercice: Préremplir avec les dates de <2>l'exercice 2022</2> ou de
<6>l'exercice 2023</6>
impotSociété:
warning: "Ce simulateur sadresse aux <2>TPE</2> : il prend en compte les taux
réduits de limpôt sur les sociétés."

View File

@ -5,18 +5,23 @@ import styled from 'styled-components'
import { TrackPage } from '@/components/ATInternetTracking'
import Value from '@/components/EngineValue'
import Notifications from '@/components/Notifications'
import { SimulationGoal, SimulationGoals } from '@/components/Simulation'
import {
SimulationContainer,
SimulationGoal,
SimulationGoals,
} from '@/components/Simulation'
import RuleInput from '@/components/conversation/RuleInput'
import Warning from '@/components/ui/WarningBlock'
import { FromTop } from '@/components/ui/animate'
import { H2 } from '@/design-system/typography/heading'
import { Body, Intro } from '@/design-system/typography/paragraphs'
import { updateSituation } from '@/store/actions/actions'
import { Link } from '@/design-system/typography/link'
import { Body, Intro, SmallBody } from '@/design-system/typography/paragraphs'
import { batchUpdateSituation, updateSituation } from '@/store/actions/actions'
import { situationSelector } from '@/store/selectors/simulationSelectors'
export default function ISSimulation() {
return (
<>
<SimulationContainer>
<Warning
localStorageKey={'app::simulateurs:warning-folded:v1:impôt-societé'}
>
@ -29,6 +34,7 @@ export default function ISSimulation() {
</Body>
</Warning>
<Notifications />
<SimulationGoals
toggles={<ExerciceDate />}
legend="Résultat imposable de l'entreprise"
@ -36,7 +42,7 @@ export default function ISSimulation() {
<SimulationGoal dottedName="entreprise . imposition . IS . résultat imposable" />
</SimulationGoals>
<Explanations />
</>
</SimulationContainer>
)
}
@ -45,29 +51,70 @@ const ExerciceDateContainer = styled.div`
justify-content: flex-end;
align-items: center;
gap: 0.5rem;
margin-top: 1rem;
margin-bottom: 0.5rem;
`
function ExerciceDate() {
const dispatch = useDispatch()
return (
<ExerciceDateContainer>
<RuleInput
dottedName={'entreprise . exercice . début'}
showDefaultDateValue
onChange={(x) =>
dispatch(updateSituation('entreprise . exercice . début', x))
}
/>{' '}
<RuleInput
dottedName={'entreprise . exercice . fin'}
showDefaultDateValue
onChange={(x) =>
dispatch(updateSituation('entreprise . exercice . fin', x))
}
<>
<SmallBody
css={`
align-self: flex-end;
`}
>
<Trans i18nKey={'impot-société.préremplir-exercice'}>
Préremplir avec les dates de{' '}
<Link
onPress={() => {
dispatch(
batchUpdateSituation({
'entreprise . exercice . début': '01/01/2022',
'entreprise . exercice . fin': '31/12/2022',
})
)
}}
>
l'exercice 2022
</Link>{' '}
ou de{' '}
<Link
onPress={() => {
dispatch(
batchUpdateSituation({
'entreprise . exercice . début': '01/01/2023',
'entreprise . exercice . fin': '31/12/2023',
})
)
}}
>
l'exercice 2023
</Link>
</Trans>
</SmallBody>
<div
css={`
flex: 1;
`}
/>
</ExerciceDateContainer>
<ExerciceDateContainer>
<RuleInput
dottedName={'entreprise . exercice . début'}
showDefaultDateValue
onChange={(x) =>
dispatch(updateSituation('entreprise . exercice . début', x))
}
/>{' '}
<RuleInput
dottedName={'entreprise . exercice . fin'}
showDefaultDateValue
onChange={(x) =>
dispatch(updateSituation('entreprise . exercice . fin', x))
}
/>
</ExerciceDateContainer>
</>
)
}