cible:{' '}
{makeJsx(explanation.cible)}
montant à atteindre:{' '}
{makeJsx(explanation.montant)}
}
/>
)
}
}
export let mecanismSelection = (recurse, k, v) => {
if (v.composantes) {
//mécanisme de composantes. Voir known-mecanisms.md/composantes
return decompose(recurse, k, v)
}
let dataSourceName = v['données']
let dataSearchField = v['dans']
let dataTargetName = v['renvoie']
let explanation = recurse(v['cherche'])
let evaluate = (cache, situationGate, parsedRules, node) => {
let explanation = evaluateNode(
cache,
situationGate,
parsedRules,
node.explanation
),
dataSource = findRuleByName(parsedRules, dataSourceName),
data = dataSource ? dataSource['data'] : null,
dataKey = explanation.nodeValue,
found =
data && dataKey && dataSearchField
? find(item => item[dataSearchField] == dataKey, data)
: null,
// return 0 if we found a match for the lookup but not for the specific field,
// so that component sums don't sum to null
nodeValue =
(found &&
found[dataTargetName] &&
Number.parseFloat(found[dataTargetName]) / 100) ||
0,
missingVariables = explanation.missingVariables
return rewriteNode(node, nodeValue, explanation, missingVariables)
}
let SelectionView = buildSelectionView(dataTargetName)
return {
evaluate,
explanation,
// eslint-disable-next-line
jsx: (nodeValue, explanation) => (
)
}
}
export let mecanismSynchronisation = (recurse, k, v) => {
let evaluate = (cache, situationGate, parsedRules, node) => {
let APIExplanation = evaluateNode(
cache,
situationGate,
parsedRules,
node.explanation.API
)
let nodeValue =
val(APIExplanation) == null
? null
: path(v.chemin.split(' . '))(val(APIExplanation))
let missingVariables =
val(APIExplanation) === null ? { [APIExplanation.dottedName]: 1 } : {}
let explanation = { ...v, API: APIExplanation }
return rewriteNode(node, nodeValue, explanation, missingVariables)
}
return {
explanation: { ...v, API: recurse(v.API) },
evaluate,
jsx: function Synchronisation(nodeValue, explanation) {
return (
Obtenu à partir de la saisie
)
},
category: 'mecanism',
name: 'synchronisation'
}
}
export let mecanismError = (recurse, k, v) => {
throw new Error("Le mécanisme '" + k + "' est inconnu !" + v)
}