Ajout d'un paramètre withDefaultValues dans l'API de la lib

pull/891/head
Maxime Quandalle 2020-02-14 09:56:19 +01:00
parent 8a8dc37830
commit ccbfb35a4d
No known key found for this signature in database
GPG Key ID: 428641C03D29CA10
2 changed files with 7 additions and 3 deletions

View File

@ -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": [

View File

@ -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() {