From 21a45c1afcd2cf9dfc18305ef8eebc98634ed58c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Rialland?= Date: Thu, 24 Mar 2022 17:21:17 +0100 Subject: [PATCH] Cache les prix / mois LFR1 non applicable --- .../ExonerationCovid/FormulaireS1S1Bis.tsx | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) 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]