From 1a3a43cbfde85c38b393fa6100083eac354ab191 Mon Sep 17 00:00:00 2001 From: David Smadja <david.smadja@assemblee-nationale.fr> Date: Mon, 31 Mar 2025 10:24:34 +0200 Subject: [PATCH] Add variable exclusion --- src/scripts/generate_openfisca_tests_yaml.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/scripts/generate_openfisca_tests_yaml.ts b/src/scripts/generate_openfisca_tests_yaml.ts index b0e6adedd..3ba6b7998 100644 --- a/src/scripts/generate_openfisca_tests_yaml.ts +++ b/src/scripts/generate_openfisca_tests_yaml.ts @@ -164,13 +164,13 @@ function replaceValuesFromReplacedKeys( return newObj } -function removeZeroValues(obj: any): any { +function removeZeroValuesAndExcludedVariables(obj: any): any { if (typeof obj !== "object" || obj === null) { return obj } if (Array.isArray(obj)) { - return obj.map(removeZeroValues) + return obj.map(removeZeroValuesAndExcludedVariables) } const newObj: any = {} @@ -180,11 +180,14 @@ function removeZeroValues(obj: any): any { const value = obj[key] if (typeof value === "object" && value !== null) { - if (Object.values(value).every((v) => v === 0 || v === null)) { + if ( + Object.values(value).every((v) => v === 0 || v === null) || + key === "prelevements_sociaux_menage" + ) { continue } - const cleanedValue = removeZeroValues(value) + const cleanedValue = removeZeroValuesAndExcludedVariables(value) if (Object.keys(cleanedValue).length > 0) { newObj[key] = cleanedValue } @@ -205,7 +208,7 @@ function cleanSimulatedJson(jsonData: any): any { jsonData[section] = Object.fromEntries( Object.entries(jsonData[section]).map(([key, value]) => [ key, - removeZeroValues(value), + removeZeroValuesAndExcludedVariables(value), ]), ) } -- GitLab