From 3bb93a462ef08dc8de665ed0c060b0e946941673 Mon Sep 17 00:00:00 2001 From: Mael Date: Tue, 27 Nov 2018 16:35:42 +0000 Subject: [PATCH] =?UTF-8?q?:bug:=20:gear:=20Erreur=20d'=C3=A9valuation=20d?= =?UTF-8?q?es=20variables=20manquantes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/engine/rules.js | 14 +++++++++----- source/engine/traverse.js | 17 +++++++++-------- source/engine/treatVariable.js | 3 ++- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/source/engine/rules.js b/source/engine/rules.js index 159895c20..961dc8537 100644 --- a/source/engine/rules.js +++ b/source/engine/rules.js @@ -25,7 +25,9 @@ import { reduced, range, last, - trim + trim, + isNil, + find } from 'ramda' import possibleVariableTypes from './possibleVariableTypes.yaml' import marked from './marked' @@ -278,10 +280,12 @@ export let findParentDependency = (rules, rule) => { // When it is resolved to false, then the whole branch under it is disactivated (non applicable) // It lets those children omit obvious and repetitive parent applicability tests let parentDependencies = ruleParents(rule.dottedName).map(joinName) - return parentDependencies - .map(parent => findRuleByDottedName(rules, parent)) - .find( + return pipe( + map(parent => findRuleByDottedName(rules, parent)), + reject(isNil), + find( //Find the first "calculable" parent - ({ question, format }) => question && !format //implicitly, the format is boolean + ({ question, format, formule }) => question && !format && !formule //implicitly, the format is boolean ) + )(parentDependencies) } diff --git a/source/engine/traverse.js b/source/engine/traverse.js index a60c6dd7f..018b95e4e 100644 --- a/source/engine/traverse.js +++ b/source/engine/traverse.js @@ -113,6 +113,9 @@ export let treatRuleRoot = (rules, rule) => { }, node ), + a = + node.dottedName.includes('jeune va') && + console.log(evaluated['parentDependency']), parentValue = val(evaluated['parentDependency']), formuleValue = val(evaluated['formule']), isApplicable = do { @@ -137,9 +140,7 @@ export let treatRuleRoot = (rules, rule) => { } = evaluated let condMissing = - val(notApplicable) === true - ? {} - : val(applicable) === false + isApplicable === false ? {} : merge( (parentDependency && parentDependency.missingVariables) || {}, @@ -173,9 +174,8 @@ export let treatRuleRoot = (rules, rule) => { // condition d'applicabilité de la règle parentDependency: parent => { - console.log('pd', parent.dottedName) + console.log('pd from ', rule.dottedName, parent.dottedName) let node = treat(rules, rule)(parent.dottedName) - console.log('pdnode', node) let jsx = (nodeValue, explanation) => ( @@ -253,9 +253,10 @@ export let treatRuleRoot = (rules, rule) => { if (level === 'bloquant' && !isInputControl) { throw new Error( - 'Un contrôle ne peut être bloquant et invoquer des calculs de variables' + - control['si'] + - level + `Un contrôle ne peut être bloquant et invoquer des calculs de variables : + ${control['si']} + ${level} + ` ) } diff --git a/source/engine/treatVariable.js b/source/engine/treatVariable.js index f79376346..6f4256ad7 100644 --- a/source/engine/treatVariable.js +++ b/source/engine/treatVariable.js @@ -30,7 +30,8 @@ export let treatVariable = (rules, rule, filter) => parseResult => { variableHasFormula || findParentDependency(rules, variable)) - console.log(dottedName, 'needseval') + // if (dottedName.includes('jeune va')) debugger + let explanation = needsEvaluation ? evaluateNode(cache, situation, parsedRules, variable) : variable