From a0105e25a094824c38447aa9c5a03a36a7ced190 Mon Sep 17 00:00:00 2001 From: Martial Maillot Date: Thu, 29 Feb 2024 16:53:05 +0100 Subject: [PATCH] =?UTF-8?q?fix(indemnite-licenciement):=20erreur=20lors=20?= =?UTF-8?q?du=20calcul=20du=20l=C3=A9gal=20suite=20refacto=20(#5660)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../__tests__/cc3248.test.tsx | 28 ++++++++++++++ .../src/modeles/common/factory/seniority.ts | 15 +++++--- .../1672_societes_assurances/seniority.ts | 2 +- .../16_transports_routiers/seniority.ts | 2 +- .../conventions/3248_metallurgie/seniority.ts | 38 ++++++++++++------- .../conventions/413_handicap/seniority.ts | 2 +- .../seniority.ts | 8 ++-- .../IndemniteLicenciementPublicodes.ts | 22 ++++------- 8 files changed, 76 insertions(+), 41 deletions(-) diff --git a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/__tests__/cc3248.test.tsx b/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/__tests__/cc3248.test.tsx index 9c0e9c5169..f1d030ee86 100644 --- a/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/__tests__/cc3248.test.tsx +++ b/packages/code-du-travail-frontend/src/outils/IndemniteLicenciement/__tests__/cc3248.test.tsx @@ -63,5 +63,33 @@ describe("Indemnité licenciement - CC 3248", () => { // Validation que l'on est bien sur l'étape ancienneté expect(ui.activeStep.query()).toHaveTextContent("Salaires"); }); + + test(`scénario complet`, () => { + // vérification que l'on demande si le salaire a eu des primes pour un cadre + userAction + .changeInputList( + ui.information.agreement3248.proCategory.get(), + "'A, B, C, D ou E'" + ) + .click(ui.information.agreement3248.dayContract.oui.get()) + .click(ui.information.agreement3248.alwaysDayContract.oui.get()) + .click(ui.information.agreement3248.hasBeenCadre.non.get()) + .click(ui.information.agreement3248.absencesProlongesRepetes.non.get()) + .click(ui.next.get()) + .setInput(ui.seniority.startDate.get(), "01/01/2021") + .setInput(ui.seniority.notificationDate.get(), "30/06/2024") + .setInput(ui.seniority.endDate.get(), "30/06/2024") + .click(ui.seniority.hasAbsence.non.get()) + .click(ui.next.get()) + .click(ui.salary.hasPartialTime.non.get()) + .click(ui.salary.hasSameSalary.oui.get()) + .setInput(ui.salary.sameSalaryValue.get(), "2668") + .click(ui.next.get()) + .click(ui.result.resultatLegal.get()) + + expect(ui.activeStep.query()).toHaveTextContent("Indemnité"); + expect(ui.result.resultat.get()).toHaveTextContent("3501,75"); + expect(ui.result.resultatLegal.get()).toHaveTextContent("2334.5"); + }); }); }); diff --git a/packages/code-du-travail-modeles/src/modeles/common/factory/seniority.ts b/packages/code-du-travail-modeles/src/modeles/common/factory/seniority.ts index b83a32e8f8..de8face15b 100644 --- a/packages/code-du-travail-modeles/src/modeles/common/factory/seniority.ts +++ b/packages/code-du-travail-modeles/src/modeles/common/factory/seniority.ts @@ -35,10 +35,13 @@ import { Seniority3239, Seniority3248, } from "../../conventions"; +import type { ISeniority } from "../index"; import { SupportedCcIndemniteLicenciement } from "../index"; export class SeniorityFactory { - create(idcc: T | null): any { + create( + idcc: T | null + ): ISeniority { switch (idcc) { case SupportedCcIndemniteLicenciement.IDCC2511: return new Seniority2511(); @@ -55,13 +58,13 @@ export class SeniorityFactory { case SupportedCcIndemniteLicenciement.IDCC1527: return new Seniority1527(); case SupportedCcIndemniteLicenciement.IDCC0016: - return new Seniority16(); + return new Seniority16() as ISeniority; case SupportedCcIndemniteLicenciement.IDCC0292: return new Seniority0292(); case SupportedCcIndemniteLicenciement.IDCC3239: return new Seniority3239(); case SupportedCcIndemniteLicenciement.IDCC650: - return new Seniority650(); + return new Seniority650() as ISeniority; case SupportedCcIndemniteLicenciement.IDCC2216: return new Seniority2216(); case SupportedCcIndemniteLicenciement.IDCC0044: @@ -73,7 +76,7 @@ export class SeniorityFactory { case SupportedCcIndemniteLicenciement.IDCC2609: return new Seniority2609(); case SupportedCcIndemniteLicenciement.IDCC413: - return new Seniority413(); + return new Seniority413() as ISeniority; case SupportedCcIndemniteLicenciement.IDCC1516: return new Seniority1516(); case SupportedCcIndemniteLicenciement.IDCC1517: @@ -93,7 +96,7 @@ export class SeniorityFactory { case SupportedCcIndemniteLicenciement.IDCC1606: return new Seniority1606(); case SupportedCcIndemniteLicenciement.IDCC1672: - return new Seniority1672(); + return new Seniority1672() as ISeniority; case SupportedCcIndemniteLicenciement.IDCC1483: return new Seniority1483(); case SupportedCcIndemniteLicenciement.IDCC1702: @@ -107,7 +110,7 @@ export class SeniorityFactory { case SupportedCcIndemniteLicenciement.IDCC2120: return new Seniority2120(); case SupportedCcIndemniteLicenciement.IDCC3248: - return new Seniority3248(); + return new Seniority3248() as ISeniority; case SupportedCcIndemniteLicenciement.default: default: return new SeniorityLegal(); diff --git a/packages/code-du-travail-modeles/src/modeles/conventions/1672_societes_assurances/seniority.ts b/packages/code-du-travail-modeles/src/modeles/conventions/1672_societes_assurances/seniority.ts index 4f6efde073..92f266c95a 100644 --- a/packages/code-du-travail-modeles/src/modeles/conventions/1672_societes_assurances/seniority.ts +++ b/packages/code-du-travail-modeles/src/modeles/conventions/1672_societes_assurances/seniority.ts @@ -16,7 +16,7 @@ import { accumulateAbsenceByYear, MotifKeys } from "../../common"; import { SeniorityDefault } from "../../common/seniority"; export type CC1672SeniorityProps = DefaultSeniorityProps & { - isExecutive: boolean; + isExecutive?: boolean; becameExecutiveAt?: string; }; diff --git a/packages/code-du-travail-modeles/src/modeles/conventions/16_transports_routiers/seniority.ts b/packages/code-du-travail-modeles/src/modeles/conventions/16_transports_routiers/seniority.ts index a2698cfab9..6a2b8b0319 100644 --- a/packages/code-du-travail-modeles/src/modeles/conventions/16_transports_routiers/seniority.ts +++ b/packages/code-du-travail-modeles/src/modeles/conventions/16_transports_routiers/seniority.ts @@ -15,7 +15,7 @@ import { accumulateAbsenceByYear } from "../../common"; import { SeniorityDefault } from "../../common/seniority"; export type CC0016SeniorityProps = DefaultSeniorityProps & { - isExecutive: boolean; + isExecutive?: boolean; becameExecutiveAt?: string; }; diff --git a/packages/code-du-travail-modeles/src/modeles/conventions/3248_metallurgie/seniority.ts b/packages/code-du-travail-modeles/src/modeles/conventions/3248_metallurgie/seniority.ts index a0afb5085d..a4cc71df2f 100644 --- a/packages/code-du-travail-modeles/src/modeles/conventions/3248_metallurgie/seniority.ts +++ b/packages/code-du-travail-modeles/src/modeles/conventions/3248_metallurgie/seniority.ts @@ -23,16 +23,16 @@ import { accumulateAbsenceByYear, MotifKeys, parseDate } from "../../common"; import { SeniorityDefault } from "../../common/seniority"; export type CC3248SeniorityProps = DefaultSeniorityProps & { - categoriePro: "'A, B, C, D ou E'" | "'F, G, H ou I'"; - hasBeenDayContract: boolean; - hasBeenExecutive: boolean; + categoriePro?: "'A, B, C, D ou E'" | "'F, G, H ou I'"; + hasBeenDayContract?: boolean; + hasBeenExecutive?: boolean; dateBecomeDayContract?: string; }; export type CC3248SeniorityRequiredProps = DefaultSeniorityRequiredProps & { - categoriePro: "'A, B, C, D ou E'" | "'F, G, H ou I'"; - hasBeenDayContract: boolean; - hasBeenExecutive: boolean; + categoriePro?: "'A, B, C, D ou E'" | "'F, G, H ou I'"; + hasBeenDayContract?: boolean; + hasBeenExecutive?: boolean; dateBecomeDayContract?: string; }; @@ -74,6 +74,11 @@ export class Seniority3248 extends SeniorityDefault