diff --git a/source/engine/treatVariable.js b/source/engine/treatVariable.js index 1c019e92f..3792ed33b 100644 --- a/source/engine/treatVariable.js +++ b/source/engine/treatVariable.js @@ -28,12 +28,14 @@ export let treatVariable = (rules, rule, filter) => parseResult => { node.explanation.dottedName ) - let variablePeriod = ruleToTransform['période'] || situation('période') + let environmentPeriod = situation('période') || 'mois' + let callingPeriod = rule['période'] || environmentPeriod + let calledPeriod = ruleToTransform['période'] || environmentPeriod let newNodeValue = - rule['période'] === 'mois' && variablePeriod === 'année' + callingPeriod === 'mois' && calledPeriod === 'année' ? nodeValue / 12 - : rule['période'] === 'année' && variablePeriod === 'mois' + : callingPeriod === 'année' && calledPeriod === 'mois' ? nodeValue * 12 : nodeValue diff --git a/test/mécanismes/période.yaml b/test/mécanismes/période.yaml index 9cb95dd6e..022c6f3e4 100644 --- a/test/mécanismes/période.yaml +++ b/test/mécanismes/période.yaml @@ -105,3 +105,19 @@ assiette deux: 3000 valeur attendue: 300 +- nom: assiette trois + période: année + format: € + +- test: Périodes, variable neutre appelant variable annuelle + formule: + multiplication: + assiette: assiette trois + taux: 10% + + exemples: + - situation: + période: mois + assiette trois: 36000 + valeur attendue: 300 +