Code plus prévisible

pull/529/head
Mael 2019-05-14 13:52:23 +02:00
parent a7d88e8514
commit 363d2795e8
3 changed files with 13 additions and 8 deletions

View File

@ -904,3 +904,11 @@ export let mecanismSynchronisation = (recurse, k, v) => {
export let mecanismError = (recurse, k, v) => {
throw new Error("Le mécanisme '" + k + "' est inconnu !" + v)
}
export let mecanismOnePossibility = (recurse, k, v) => ({
...v,
'une possibilité': 'oui',
evaluate: (cache, situationGate, parsedRules, node) => ({
...node,
missingVariables: { [node.dottedName]: 1 }
})
})

View File

@ -44,7 +44,8 @@ import {
mecanismReduction,
mecanismSum,
mecanismSynchronisation,
mecanismVariations
mecanismVariations,
mecanismOnePossibility
} from './mecanisms'
import { Node } from './mecanismViews/common'
import { treat } from './traverse'
@ -228,11 +229,7 @@ export let treatObject = (rules, rule, treatOptions) => rawNode => {
'le maximum de': mecanismMax,
'le minimum de': mecanismMin,
complément: mecanismComplement,
'une possibilité': always({
...v,
'une possibilité': 'oui',
missingVariables: { [rule.dottedName]: 1 }
}),
'une possibilité': mecanismOnePossibility,
'inversion numérique': mecanismInversion(rule.dottedName),
allègement: mecanismReduction,
variations: mecanismVariations,

View File

@ -28,7 +28,7 @@ export let treatVariable = (rules, rule, filter) => parseResult => {
situationValue == null &&
(variableHasCond ||
variableHasFormula ||
findParentDependency(rules, variable))
findParentDependency(parsedRules, variable))
// if (dottedName.includes('jeune va')) debugger
@ -131,7 +131,7 @@ export let treatVariableTransforms = (rules, rule) => parseResult => {
let supportedPeriods = ['mois', 'année', 'flexible']
if (nodeValue == null) return filteredNode
let ruleToTransform = findRuleByDottedName(
rules,
parsedRules,
filteredNode.explanation.dottedName
)