diff --git a/mon-entreprise/package.json b/mon-entreprise/package.json index c4ed41c39..840aa1240 100644 --- a/mon-entreprise/package.json +++ b/mon-entreprise/package.json @@ -70,8 +70,8 @@ "scripts": { "prepare": "node scripts/prepare.js", "build": "yarn run build:prod && yarn run build:legacy", - "build:prod": "yarn run webpack --config webpack.prod.js --progress --loglevel notice", - "build:legacy": "yarn run webpack --config webpack.prod.legacyBrowser.js --progress --loglevel notice", + "build:prod": "yarn run webpack --config webpack.prod.js", + "build:legacy": "yarn run webpack --config webpack.prod.legacyBrowser.js", "build:stats": "webpack --config webpack.prod.js --profile --json > stats.json", "build:analyze-bundle": "ANALYZE_BUNDLE=1 yarn run build", "build:dev": "FR_SITE='http://localhost:5000${path}' EN_SITE='http://localhost:5001${path}' yarn run build", diff --git a/mon-entreprise/source/rules/impôt.yaml b/mon-entreprise/source/rules/impôt.yaml index ec7d02f85..cac0854f9 100644 --- a/mon-entreprise/source/rules/impôt.yaml +++ b/mon-entreprise/source/rules/impôt.yaml @@ -431,7 +431,7 @@ impôt . foyer fiscal . impôt sur le revenu . impôt brut: - recalcul: règle: impôt brut . sans plafonnement avec: - nombre de parts . rattachées: 0 + nombre de parts . rattachées: 0 part - (- quotient familial . plafond avantage) impôt . foyer fiscal . impôt sur le revenu . impôt brut . sans plafonnement: diff --git a/publicodes/source/mecanisms.tsx b/publicodes/source/mecanisms.tsx index 2918cfc88..6b42196c6 100644 --- a/publicodes/source/mecanisms.tsx +++ b/publicodes/source/mecanisms.tsx @@ -239,11 +239,27 @@ export const mecanismRecalcul = dottedNameContext => (recurse, k, v) => { if (cache._meta.inRecalcul) { return defaultNode(false) } - const recalculCache = { _meta: { ...cache._meta, inRecalcul: true } } // Create an empty cache - const amendedSituation = map( - value => evaluateNode(cache, situation, parsedRules, value), + + const amendedSituation = Object.fromEntries( node.explanation.amendedSituation + .map(([originRule, replacement]) => [ + evaluateNode(cache, situation, parsedRules, originRule), + evaluateNode(cache, situation, parsedRules, replacement) + ]) + .filter( + ([originRule, replacement]) => + originRule.nodeValue !== replacement.nodeValue || + serializeUnit(originRule.unit) !== serializeUnit(replacement.unit) + ) + .map(([originRule, replacement]) => [ + originRule.dottedName, + replacement + ]) ) + // Optimisation : no need for recalcul if situation is the same + const recalculCache = Object.keys(amendedSituation).length + ? { _meta: { ...cache._meta, inRecalcul: true } } // Create an empty cache + : cache const evaluatedNode = evaluateNode( recalculCache, @@ -266,12 +282,10 @@ export const mecanismRecalcul = dottedNameContext => (recurse, k, v) => { } } - const amendedSituation = Object.fromEntries( - Object.keys(v.avec).map(dottedName => [ - recurse(dottedName).dottedName, - recurse(v.avec[dottedName]) - ]) - ) + const amendedSituation = Object.keys(v.avec).map(dottedName => [ + recurse(dottedName), + recurse(v.avec[dottedName]) + ]) const defaultRuleToEvaluate = dottedNameContext const nodeToEvaluate = recurse(v.règle ?? defaultRuleToEvaluate) return {