🐛 ⚙️ Erreur d'évaluation des variables manquantes

barème-continu
Mael 2018-11-27 16:35:42 +00:00
parent 81340b4510
commit 3bb93a462e
3 changed files with 20 additions and 14 deletions

View File

@ -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)
}

View File

@ -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) => (
<ShowValuesConsumer>
@ -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}
`
)
}

View File

@ -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