Ajout d'un paramètre withDefaultValues dans l'API de la lib
parent
8a8dc37830
commit
ccbfb35a4d
|
@ -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": [
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Reference in New Issue