🐛 Transformation temporelle avant les filtres
parent
33060ebd62
commit
94d002e18d
|
@ -27,7 +27,8 @@ import { Node } from './mecanismViews/common'
|
|||
import {
|
||||
treatVariable,
|
||||
treatNegatedVariable,
|
||||
treatFilteredVariable
|
||||
treatFilteredVariable,
|
||||
treatPeriodTransform
|
||||
} from './treatVariable'
|
||||
import { treat } from './traverse'
|
||||
import knownMecanisms from './known-mecanisms.yaml'
|
||||
|
@ -90,9 +91,13 @@ export let treatString = (rules, rule) => rawNode => {
|
|||
)
|
||||
|
||||
if (parseResult.category == 'variable')
|
||||
return treatVariable(rules, rule)(parseResult)
|
||||
return treatPeriodTransform(rules, rule)(
|
||||
treatVariable(rules, rule)(parseResult)
|
||||
)
|
||||
if (parseResult.category == 'filteredVariable')
|
||||
return treatFilteredVariable(rules, rule)
|
||||
return treatPeriodTransform(rules, rule)(
|
||||
treatFilteredVariable(rules, rule)(parseResult)
|
||||
)
|
||||
if (parseResult.category == 'negatedVariable')
|
||||
return treatNegatedVariable(
|
||||
treatVariable(rules, rule)(parseResult.variable)
|
||||
|
@ -154,10 +159,19 @@ export let treatString = (rules, rule) => rawNode => {
|
|||
|
||||
let explanation = parseResult.explanation.map(
|
||||
cond([
|
||||
[propEq('category', 'variable'), treatVariable(rules, rule)],
|
||||
[
|
||||
propEq('category', 'variable'),
|
||||
parseResult =>
|
||||
treatPeriodTransform(rules, rule)(
|
||||
treatVariable(rules, rule)(parseResult)
|
||||
)
|
||||
],
|
||||
[
|
||||
propEq('category', 'filteredVariable'),
|
||||
treatFilteredVariable(rules, rule)
|
||||
parseResult =>
|
||||
treatPeriodTransform(rules, rule)(
|
||||
treatFilteredVariable(rules, rule)(parseResult)
|
||||
)
|
||||
],
|
||||
[
|
||||
propEq('category', 'value'),
|
||||
|
|
|
@ -5,8 +5,9 @@ import { evaluateNode, rewriteNode, makeJsx } from './evaluation'
|
|||
import { getSituationValue } from './variables'
|
||||
import { Trans } from 'react-i18next'
|
||||
|
||||
export let treatVariable = (rules, rule, filter) => parseResult => {
|
||||
let variable = treatVariableTimeless(rules, rule, filter)(parseResult)
|
||||
// This function is a wrapper that can apply temporal transformations to the value of the variable.
|
||||
// See the période.yaml test suite for details
|
||||
export let treatPeriodTransform = (rules, rule) => variable => {
|
||||
let evaluate = (cache, situation, parsedRules, node) => {
|
||||
let explanation = evaluateNode(
|
||||
cache,
|
||||
|
@ -55,7 +56,7 @@ export let treatVariable = (rules, rule, filter) => parseResult => {
|
|||
}
|
||||
}
|
||||
|
||||
export let treatVariableTimeless = (rules, rule, filter) => parseResult => {
|
||||
export let treatVariable = (rules, rule, filter) => parseResult => {
|
||||
let evaluate = (cache, situation, parsedRules, node) => {
|
||||
let dottedName = node.dottedName,
|
||||
// On va vérifier dans le cache courant, dict, si la variable n'a pas été déjà évaluée
|
||||
|
|
|
@ -123,8 +123,11 @@ const analysisToCotisations = (
|
|||
'contrat salarié . cotisations patronales'
|
||||
]
|
||||
.map(name => analysis.cache[name])
|
||||
// the last 'explanation' is because variables are wrapped in a period transform node
|
||||
.map(pathOr([], ['explanation', 'formule', 'explanation', 'explanation']))
|
||||
.reduce(concat, [])
|
||||
.map(prop('explanation'))
|
||||
|
||||
const cotisations = pipe(
|
||||
groupBy(prop('dottedName')),
|
||||
values,
|
||||
|
|
Loading…
Reference in New Issue