From c24d838c15861a6427d65ec3aebe54e974cfc0e7 Mon Sep 17 00:00:00 2001 From: Mael Date: Mon, 1 Oct 2018 08:22:05 +0000 Subject: [PATCH] =?UTF-8?q?:gear:=20:white=5Fcheck=5Fmark:=20Meilleure=20i?= =?UTF-8?q?mpl=C3=A9mentation=20des=20p=C3=A9riodes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/engine/treatVariable.js | 8 +++++--- test/mécanismes/période.yaml | 16 ++++++++++++++++ 2 files changed, 21 insertions(+), 3 deletions(-) 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 +