From 300e0c587edbef6d399cc24fe7e734f1e9127bd1 Mon Sep 17 00:00:00 2001 From: Johan Girod Date: Wed, 16 Dec 2020 17:50:54 +0100 Subject: [PATCH] =?UTF-8?q?:fire:=20R=C3=A9ecrit=20la=20logique=20de=20Pay?= =?UTF-8?q?Slip?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mon-entreprise/source/components/PaySlip.tsx | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/mon-entreprise/source/components/PaySlip.tsx b/mon-entreprise/source/components/PaySlip.tsx index f85c08bd5..4813f3550 100644 --- a/mon-entreprise/source/components/PaySlip.tsx +++ b/mon-entreprise/source/components/PaySlip.tsx @@ -181,7 +181,7 @@ export default function PaySlip() { function findReferenceInNode( dottedName: DottedName, - node: EvaluatedNode + node: ASTNode ): EvaluatedNode | null { return reduceAST<(EvaluatedNode & { nodeKind: 'reference' }) | null>( (acc, node) => { @@ -201,16 +201,20 @@ function findReferenceInNode( function Cotisation({ dottedName }: { dottedName: DottedName }) { const language = useTranslation().i18n.language const engine = useContext(EngineContext) - const cotisationsSalariales = engine.evaluate( - engine.getRule('contrat salarié . cotisations . salariales') + const partSalariale = engine.evaluate( + findReferenceInNode( + dottedName, + engine.getRule('contrat salarié . cotisations . salariales') + ) ?? '0' ) - const cotisationsPatronales = engine.evaluate( - engine.getRule('contrat salarié . cotisations . patronales') + const partPatronale = engine.evaluate( + findReferenceInNode( + dottedName, + engine.getRule('contrat salarié . cotisations . patronales') + ) ?? '0' ) - const partSalariale = findReferenceInNode(dottedName, cotisationsSalariales) - const partPatronale = findReferenceInNode(dottedName, cotisationsPatronales) - if (!partPatronale?.nodeValue && !partSalariale?.nodeValue) { + if (!partPatronale.nodeValue && !partSalariale.nodeValue) { return null } return (