diff --git a/source/engine/mecanismViews/Barème.js b/source/engine/mecanismViews/Barème.js index 25a451d4b..35550c1fe 100644 --- a/source/engine/mecanismViews/Barème.js +++ b/source/engine/mecanismViews/Barème.js @@ -17,14 +17,16 @@ export default function Barème(nodeValue, explanation) { {makeJsx(explanation.assiette)} -
  • - - multiplicateur des tranches:{' '} - - - {makeJsx(explanation['multiplicateur des tranches'])} - -
  • + {explanation['multiplicateur des tranches'].nodeValue !== 1 && ( +
  • + + multiplicateur des tranches:{' '} + + + {makeJsx(explanation['multiplicateur des tranches'])} + +
  • + )} diff --git a/source/engine/treat.js b/source/engine/treat.js index 93c6f9b6b..709acf58d 100644 --- a/source/engine/treat.js +++ b/source/engine/treat.js @@ -90,14 +90,7 @@ export let treatString = (rules, rule) => rawNode => { // We don't need to handle category == 'value' because YAML then returns it as // numerical value, not a String: it goes to treatNumber - if (parseResult.category == 'percentage') { - return { - nodeValue: parseResult.nodeValue, - category: 'percentage', - // eslint-disable-next-line - jsx: () => {rawNode} - } - } + if (parseResult.category == 'percentage') return treatPercentage(parseResult) if ( parseResult.category == 'calcExpression' || @@ -154,17 +147,7 @@ export let treatString = (rules, rule) => rawNode => { jsx: nodeValue => {nodeValue} }) ], - [ - propEq('category', 'percentage'), - node => ({ - nodeValue: node.nodeValue, - category: 'percentage', - // eslint-disable-next-line - jsx: nodeValue => ( - {nodeValue * 100}% - ) - }) - ] + [propEq('category', 'percentage'), treatPercentage] ]) ), operator = parseResult.operator @@ -206,15 +189,23 @@ export let treatString = (rules, rule) => rawNode => { } } -export let treatNumber = rawNode => { - return { - text: '' + rawNode, - category: 'number', - nodeValue: rawNode, - type: 'numeric', - jsx: {rawNode} - } -} +export let treatPercentage = node => ({ + nodeValue: node.nodeValue, + category: 'percentage', + // eslint-disable-next-line + jsx: nodeValue => ( + {Math.round(nodeValue * 100)} % + ) +}) + +export let treatNumber = rawNode => ({ + text: '' + rawNode, + category: 'number', + nodeValue: rawNode, + type: 'numeric', + jsx: {rawNode} +}) + export let treatOther = rawNode => { throw new Error( 'Cette donnée : ' + rawNode + ' doit être un Number, String ou Object'