diff --git a/src/scripts/generate_openfisca_tests_yaml.ts b/src/scripts/generate_openfisca_tests_yaml.ts index b0e6adedda69e3118d2742a8a39b10a67faeb5a2..3ba6b799802448ed0ca00197e649459163c7d3d2 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), ]), ) }