Cache les prix / mois LFR1 non applicable

pull/2077/head
Jérémy Rialland 2022-03-24 17:21:17 +01:00 committed by Johan Girod
parent f6f6b187a9
commit 21a45c1afc
1 changed files with 14 additions and 6 deletions

View File

@ -23,18 +23,26 @@ const getTotalByMonth = (
Object.entries(situation)
.filter(([monthDottedName]) => monthDottedName.startsWith('mois . '))
.map(([monthDottedName]) => {
const { nodeValue } = engine.evaluate(
monthDottedName
) as EvaluatedNode<string>
const parsedRules = engine.getParsedRules()
if (!nodeValue || !(nodeValue + ' . montant mensuel' in parsedRules)) {
const exoSelected = (
engine.evaluate(monthDottedName) as EvaluatedNode<string>
).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<number>
return [monthDottedName, value]