diff --git a/source/engine/mecanismViews/Allègement.js b/source/engine/mecanismViews/Allègement.js index 6ba8e9597..93279b05d 100644 --- a/source/engine/mecanismViews/Allègement.js +++ b/source/engine/mecanismViews/Allègement.js @@ -1,60 +1,66 @@ import React from 'react' import { Node } from './common' import { makeJsx } from '../evaluation' -import { mapObjIndexed, values } from 'ramda' +import { mapObjIndexed, map, values } from 'ramda' -export default (nodeValue, explanation) => ( -
- -
  • - assiette: - {makeJsx(explanation.assiette)} -
  • - {explanation.franchise && ( -
  • - franchise: - {makeJsx(explanation.franchise)} -
  • - )} - {explanation.décote && ( -
  • - décote: - - - -
  • - )} - {explanation.abattement && ( -
  • - abattement: - {makeJsx(explanation.abattement)} -
  • - )} - - } - /> -
    -) - -let ObjectView = ({ data }) => - console.log('data', data) || ( - +export default function Allègement(nodeValue, rawExplanation) { + // properties with a nodeValue of 0 are not interesting to display + let explanation = map( + k => (k && k.nodeValue !== 0 ? k : null), + rawExplanation ) + return ( +
    + +
  • + assiette: + {makeJsx(explanation.assiette)} +
  • + {explanation.franchise && ( +
  • + franchise: + {makeJsx(explanation.franchise)} +
  • + )} + {explanation.décote && ( +
  • + décote: + + + +
  • + )} + {explanation.abattement && ( +
  • + abattement: + {makeJsx(explanation.abattement)} +
  • + )} + + } + /> +
    + ) +} + +let ObjectView = ({ data }) => ( + +) diff --git a/source/engine/mecanisms.js b/source/engine/mecanisms.js index 44cd86661..db03fea4a 100644 --- a/source/engine/mecanisms.js +++ b/source/engine/mecanisms.js @@ -103,17 +103,14 @@ let decompose = (recurse, k, v) => { } /> ) - + let filter = situationGate => c => - !situationGate('sys.filter') || - !c.composante || - (!c.composante['dû par'] || - c.composante['dû par'] == situationGate('sys.filter')) && - (!c.composante['impôt sur le revenu'] || - c.composante['impôt sur le revenu'] == situationGate('sys.filter')) - - - + !situationGate('sys.filter') || + !c.composante || + ((!c.composante['dû par'] || + c.composante['dû par'] == situationGate('sys.filter')) && + (!c.composante['impôt sur le revenu'] || + c.composante['impôt sur le revenu'] == situationGate('sys.filter'))) return { explanation, @@ -362,7 +359,11 @@ export let mecanismNumericalSwitch = (recurse, k, v) => { evaluateNode(cache, situationGate, parsedRules, child), explanation = map(evaluateOne, node.explanation), nonFalsyTerms = filter(node => node.condValue !== false, explanation), - getFirst = o => pipe(head, prop(o))(nonFalsyTerms), + getFirst = o => + pipe( + head, + prop(o) + )(nonFalsyTerms), nodeValue = // voilà le "numérique" dans le nom de ce mécanisme : il renvoie zéro si aucune condition n'est vérifiée isEmpty(nonFalsyTerms)