diff --git a/site/source/pages/Simulateurs/ExonerationCovid/FormulaireS1S1Bis.tsx b/site/source/pages/Simulateurs/ExonerationCovid/FormulaireS1S1Bis.tsx index ad719ccf9..427bad1c7 100644 --- a/site/source/pages/Simulateurs/ExonerationCovid/FormulaireS1S1Bis.tsx +++ b/site/source/pages/Simulateurs/ExonerationCovid/FormulaireS1S1Bis.tsx @@ -23,18 +23,26 @@ const getTotalByMonth = ( Object.entries(situation) .filter(([monthDottedName]) => monthDottedName.startsWith('mois . ')) .map(([monthDottedName]) => { - const { nodeValue } = engine.evaluate( - monthDottedName - ) as EvaluatedNode - const parsedRules = engine.getParsedRules() - if (!nodeValue || !(nodeValue + ' . montant mensuel' in parsedRules)) { + const exoSelected = ( + engine.evaluate(monthDottedName) as EvaluatedNode + ).nodeValue + + const exoApplicable = + typeof exoSelected === 'string' && + monthDottedName + ' . ' + exoSelected in parsedRules && + engine.evaluate(monthDottedName + ' . ' + exoSelected).nodeValue + + if ( + !exoApplicable || + !(exoSelected + ' . montant mensuel' in parsedRules) + ) { return [monthDottedName, undefined] } const value = engine.evaluate( - nodeValue + ' . montant mensuel' + exoSelected + ' . montant mensuel' ) as EvaluatedNode return [monthDottedName, value]