🎨 Eviter d'afficher une franchise de 0
parent
e5efd913fd
commit
f8456b7c24
|
@ -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) => (
|
||||
<div>
|
||||
<Node
|
||||
classes="mecanism allègement"
|
||||
name="allègement"
|
||||
value={nodeValue}
|
||||
child={
|
||||
<ul className="properties">
|
||||
<li key="assiette">
|
||||
<span className="key">assiette: </span>
|
||||
<span className="value">{makeJsx(explanation.assiette)}</span>
|
||||
</li>
|
||||
{explanation.franchise && (
|
||||
<li key="franchise">
|
||||
<span className="key">franchise: </span>
|
||||
<span className="value">{makeJsx(explanation.franchise)}</span>
|
||||
</li>
|
||||
)}
|
||||
{explanation.décote && (
|
||||
<li key="décote">
|
||||
<span className="key">décote: </span>
|
||||
<span className="value">
|
||||
<ObjectView data={explanation.décote} />
|
||||
</span>
|
||||
</li>
|
||||
)}
|
||||
{explanation.abattement && (
|
||||
<li key="abattement">
|
||||
<span className="key">abattement: </span>
|
||||
<span className="value">{makeJsx(explanation.abattement)}</span>
|
||||
</li>
|
||||
)}
|
||||
</ul>
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
|
||||
let ObjectView = ({ data }) =>
|
||||
console.log('data', data) || (
|
||||
<ul className="properties">
|
||||
{values(
|
||||
mapObjIndexed(
|
||||
(v, k) => (
|
||||
<li key={k}>
|
||||
{' '}
|
||||
<span className="key">{k}: </span>
|
||||
<span className="value">{makeJsx(v)}</span>
|
||||
</li>
|
||||
),
|
||||
data
|
||||
)
|
||||
)}
|
||||
</ul>
|
||||
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 (
|
||||
<div>
|
||||
<Node
|
||||
classes="mecanism allègement"
|
||||
name="allègement"
|
||||
value={nodeValue}
|
||||
child={
|
||||
<ul className="properties">
|
||||
<li key="assiette">
|
||||
<span className="key">assiette: </span>
|
||||
<span className="value">{makeJsx(explanation.assiette)}</span>
|
||||
</li>
|
||||
{explanation.franchise && (
|
||||
<li key="franchise">
|
||||
<span className="key">franchise: </span>
|
||||
<span className="value">{makeJsx(explanation.franchise)}</span>
|
||||
</li>
|
||||
)}
|
||||
{explanation.décote && (
|
||||
<li key="décote">
|
||||
<span className="key">décote: </span>
|
||||
<span className="value">
|
||||
<ObjectView data={explanation.décote} />
|
||||
</span>
|
||||
</li>
|
||||
)}
|
||||
{explanation.abattement && (
|
||||
<li key="abattement">
|
||||
<span className="key">abattement: </span>
|
||||
<span className="value">{makeJsx(explanation.abattement)}</span>
|
||||
</li>
|
||||
)}
|
||||
</ul>
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
let ObjectView = ({ data }) => (
|
||||
<ul className="properties">
|
||||
{values(
|
||||
mapObjIndexed(
|
||||
(v, k) => (
|
||||
<li key={k}>
|
||||
{' '}
|
||||
<span className="key">{k}: </span>
|
||||
<span className="value">{makeJsx(v)}</span>
|
||||
</li>
|
||||
),
|
||||
data
|
||||
)
|
||||
)}
|
||||
</ul>
|
||||
)
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue