🔥 Réecrit la logique de PaySlip
parent
44058b3bda
commit
300e0c587e
|
@ -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 (
|
||||
|
|
Loading…
Reference in New Issue