⚙️ Mise en valeur du plafond actif
parent
7d815bfb94
commit
857b00dbea
|
@ -29,7 +29,15 @@ export default function ProductView(nodeValue, explanation) {
|
|||
alignItems: 'baseline',
|
||||
flexWrap: 'wrap'
|
||||
}}>
|
||||
<Trans>Plafonnée à :</Trans> {makeJsx(explanation.plafond)}
|
||||
<span
|
||||
style={{
|
||||
...(explanation.plafondActif
|
||||
? { background: 'yellow' }
|
||||
: {})
|
||||
}}>
|
||||
<Trans>Plafonnée à :</Trans>
|
||||
{makeJsx(explanation.plafond)}
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
|
|
@ -1,23 +1,68 @@
|
|||
import { desugarScale } from 'Engine/mecanisms/barème';
|
||||
import { decompose, devariateExplanation } from 'Engine/mecanisms/utils';
|
||||
import { add, any, aperture, curry, equals, evolve, filter, find, head, is, isEmpty, isNil, keys, last, map, max, mergeWith, min, path, pipe, pluck, prop, propEq, reduce, reduced, reject, sort, subtract, toPairs } from 'ramda';
|
||||
import React from 'react';
|
||||
import { Trans } from 'react-i18next';
|
||||
import 'react-virtualized/styles.css';
|
||||
import { bonus, collectNodeMissing, defaultNode, evaluateArray, evaluateNode, evaluateObject, makeJsx, mergeAllMissing, mergeMissing, parseObject, rewriteNode } from './evaluation';
|
||||
import Allègement from './mecanismViews/Allègement';
|
||||
import Barème from './mecanismViews/Barème';
|
||||
import BarèmeContinu from './mecanismViews/BarèmeContinu';
|
||||
import { Node, SimpleRuleLink } from './mecanismViews/common';
|
||||
import InversionNumérique from './mecanismViews/InversionNumérique';
|
||||
import Product from './mecanismViews/Product';
|
||||
import buildSelectionView from './mecanismViews/Selection';
|
||||
import Somme from './mecanismViews/Somme';
|
||||
import Variations from './mecanismViews/Variations';
|
||||
import { disambiguateRuleReference, findRuleByDottedName, findRuleByName } from './rules';
|
||||
import { anyNull, val } from './traverse-common-functions';
|
||||
import uniroot from './uniroot';
|
||||
|
||||
import { desugarScale } from 'Engine/mecanisms/barème'
|
||||
import { decompose, devariateExplanation } from 'Engine/mecanisms/utils'
|
||||
import {
|
||||
add,
|
||||
any,
|
||||
aperture,
|
||||
curry,
|
||||
equals,
|
||||
evolve,
|
||||
filter,
|
||||
find,
|
||||
head,
|
||||
is,
|
||||
isEmpty,
|
||||
isNil,
|
||||
keys,
|
||||
last,
|
||||
map,
|
||||
max,
|
||||
mergeWith,
|
||||
min,
|
||||
path,
|
||||
pipe,
|
||||
pluck,
|
||||
prop,
|
||||
propEq,
|
||||
reduce,
|
||||
reduced,
|
||||
reject,
|
||||
sort,
|
||||
subtract,
|
||||
toPairs
|
||||
} from 'ramda'
|
||||
import React from 'react'
|
||||
import { Trans } from 'react-i18next'
|
||||
import 'react-virtualized/styles.css'
|
||||
import {
|
||||
bonus,
|
||||
collectNodeMissing,
|
||||
defaultNode,
|
||||
evaluateArray,
|
||||
evaluateNode,
|
||||
evaluateObject,
|
||||
makeJsx,
|
||||
mergeAllMissing,
|
||||
mergeMissing,
|
||||
parseObject,
|
||||
rewriteNode
|
||||
} from './evaluation'
|
||||
import Allègement from './mecanismViews/Allègement'
|
||||
import Barème from './mecanismViews/Barème'
|
||||
import BarèmeContinu from './mecanismViews/BarèmeContinu'
|
||||
import { Node, SimpleRuleLink } from './mecanismViews/common'
|
||||
import InversionNumérique from './mecanismViews/InversionNumérique'
|
||||
import Product from './mecanismViews/Product'
|
||||
import buildSelectionView from './mecanismViews/Selection'
|
||||
import Somme from './mecanismViews/Somme'
|
||||
import Variations from './mecanismViews/Variations'
|
||||
import {
|
||||
disambiguateRuleReference,
|
||||
findRuleByDottedName,
|
||||
findRuleByName
|
||||
} from './rules'
|
||||
import { anyNull, val } from './traverse-common-functions'
|
||||
import uniroot from './uniroot'
|
||||
|
||||
/* @devariate = true => This function will produce variations of a same mecanism (e.g. product) that share some common properties */
|
||||
export let mecanismVariations = (recurse, k, v, devariate) => {
|
||||
|
@ -557,14 +602,18 @@ export let mecanismProduct = (recurse, k, v) => {
|
|||
let effect = ({ assiette, taux, facteur, plafond }) => {
|
||||
let mult = (base, rate, facteur, plafond) =>
|
||||
Math.min(base, plafond) * rate * facteur
|
||||
return val(taux) === 0 ||
|
||||
val(taux) === false ||
|
||||
val(assiette) === 0 ||
|
||||
val(facteur) === 0
|
||||
? 0
|
||||
: anyNull([taux, assiette, facteur, plafond])
|
||||
? null
|
||||
: mult(val(assiette), val(taux), val(facteur), val(plafond))
|
||||
return {
|
||||
nodeValue:
|
||||
val(taux) === 0 ||
|
||||
val(taux) === false ||
|
||||
val(assiette) === 0 ||
|
||||
val(facteur) === 0
|
||||
? 0
|
||||
: anyNull([taux, assiette, facteur, plafond])
|
||||
? null
|
||||
: mult(val(assiette), val(taux), val(facteur), val(plafond)),
|
||||
additionalExplanation: { plafondActif: val(assiette) > val(plafond) }
|
||||
}
|
||||
}
|
||||
|
||||
let explanation = parseObject(recurse, objectShape, v),
|
||||
|
|
Loading…
Reference in New Issue