✨ Simplification du code
Simplification relative, car le filtrage des variables n'est pas abouti du toutpull/386/head
parent
2e213f7cc7
commit
c9d7059179
|
@ -91,12 +91,8 @@ export let treatString = (rules, rule) => rawNode => {
|
|||
|
||||
if (parseResult.category == 'variable')
|
||||
return treatVariable(rules, rule)(parseResult)
|
||||
if (parseResult.category == 'filteredVariable') {
|
||||
return treatFilteredVariable(rules, rule)(
|
||||
parseResult.filter,
|
||||
parseResult.variable
|
||||
)
|
||||
}
|
||||
if (parseResult.category == 'filteredVariable')
|
||||
return treatFilteredVariable(rules, rule)
|
||||
if (parseResult.category == 'negatedVariable')
|
||||
return treatNegatedVariable(
|
||||
treatVariable(rules, rule)(parseResult.variable)
|
||||
|
@ -156,17 +152,12 @@ export let treatString = (rules, rule) => rawNode => {
|
|||
return rewriteNode(node, nodeValue, explanation, missingVariables)
|
||||
}
|
||||
|
||||
let treatFilteredVariableClosure = parseResult =>
|
||||
treatFilteredVariable(rules, rule)(
|
||||
parseResult.filter,
|
||||
parseResult.variable
|
||||
)
|
||||
let explanation = parseResult.explanation.map(
|
||||
cond([
|
||||
[propEq('category', 'variable'), treatVariable(rules, rule)],
|
||||
[
|
||||
propEq('category', 'filteredVariable'),
|
||||
treatFilteredVariableClosure
|
||||
treatFilteredVariable(rules, rule)
|
||||
],
|
||||
[
|
||||
propEq('category', 'value'),
|
||||
|
|
|
@ -143,22 +143,25 @@ export let treatVariableTimeless = (rules, rule, filter) => parseResult => {
|
|||
}
|
||||
|
||||
// TODO - this is becoming overly specific
|
||||
export let treatFilteredVariable = (rules, rule) => (filter, parseResult) => {
|
||||
export let treatFilteredVariable = (rules, rule) => parseResult => {
|
||||
let evaluateFiltered = originalEval => (
|
||||
cache,
|
||||
situation,
|
||||
parsedRules,
|
||||
node
|
||||
) => {
|
||||
let newSituation = name => (name == 'sys.filter' ? filter : situation(name))
|
||||
let newSituation = name =>
|
||||
name == 'sys.filter' ? parseResult.filter : situation(name)
|
||||
return originalEval(cache, newSituation, parsedRules, node)
|
||||
}
|
||||
let node = treatVariable(rules, rule, filter)(parseResult),
|
||||
let node = treatVariable(rules, rule, parseResult.filter)(
|
||||
parseResult.variable
|
||||
),
|
||||
// Decorate node with the composante filter (either who is paying, either tax free)
|
||||
cotisation = {
|
||||
...node.cotisation,
|
||||
'dû par': filter,
|
||||
'impôt sur le revenu': filter
|
||||
'dû par': parseResult.filter,
|
||||
'impôt sur le revenu': parseResult.filter
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
Loading…
Reference in New Issue