From ccbfb35a4d5deed99d7db92bb21f55aa7330d5ef Mon Sep 17 00:00:00 2001 From: Maxime Quandalle Date: Fri, 14 Feb 2020 09:56:19 +0100 Subject: [PATCH] =?UTF-8?q?Ajout=20d'un=20param=C3=A8tre=20withDefaultValu?= =?UTF-8?q?es=20dans=20l'API=20de=20la=20lib?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- source/engine/index.js | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index c797c44b9..543407889 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "mon-entreprise", "license": "MIT", - "version": "1.2.3", + "version": "1.2.6", "description": "Library to compute the french social security contributions. Also a website that explains the calculations, and a generic engine to build cool forms that asks the question needed to compute an objective.", "main": "./dist/engine.js", "files": [ diff --git a/source/engine/index.js b/source/engine/index.js index a3168d45b..fe09942bb 100644 --- a/source/engine/index.js +++ b/source/engine/index.js @@ -28,12 +28,16 @@ class Engine { this.parsedRules = parseAll(rules) this.defaultValues = collectDefaults(rules) } - evaluate(targets, { defaultUnits, situation }) { + evaluate(targets, { defaultUnits, situation, withDefaultValues = true }) { this.evaluation = analyseMany( this.parsedRules, targets, defaultUnits - )(dottedName => situation[dottedName] || this.defaultValues[dottedName]) + )( + dottedName => + situation[dottedName] || + (withDefaultValues && this.defaultValues[dottedName]) + ) return this.evaluation.targets.map(({ nodeValue }) => nodeValue) } getLastEvaluationExplanations() {