Skip to content

Commit

Permalink
fix(indemnite-licenciement): erreur lors du calcul du légal suite ref…
Browse files Browse the repository at this point in the history
…acto (#5660)
  • Loading branch information
m-maillot authored Feb 29, 2024
1 parent 825026e commit a0105e2
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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");
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,13 @@ import {
Seniority3239,
Seniority3248,
} from "../../conventions";
import type { ISeniority } from "../index";
import { SupportedCcIndemniteLicenciement } from "../index";

export class SeniorityFactory {
create<T extends SupportedCcIndemniteLicenciement>(idcc: T | null): any {
create<T extends SupportedCcIndemniteLicenciement>(
idcc: T | null
): ISeniority<SupportedCcIndemniteLicenciement> {
switch (idcc) {
case SupportedCcIndemniteLicenciement.IDCC2511:
return new Seniority2511();
Expand All @@ -55,13 +58,13 @@ export class SeniorityFactory {
case SupportedCcIndemniteLicenciement.IDCC1527:
return new Seniority1527();
case SupportedCcIndemniteLicenciement.IDCC0016:
return new Seniority16();
return new Seniority16() as ISeniority<SupportedCcIndemniteLicenciement.IDCC0016>;
case SupportedCcIndemniteLicenciement.IDCC0292:
return new Seniority0292();
case SupportedCcIndemniteLicenciement.IDCC3239:
return new Seniority3239();
case SupportedCcIndemniteLicenciement.IDCC650:
return new Seniority650();
return new Seniority650() as ISeniority<SupportedCcIndemniteLicenciement.IDCC650>;
case SupportedCcIndemniteLicenciement.IDCC2216:
return new Seniority2216();
case SupportedCcIndemniteLicenciement.IDCC0044:
Expand All @@ -73,7 +76,7 @@ export class SeniorityFactory {
case SupportedCcIndemniteLicenciement.IDCC2609:
return new Seniority2609();
case SupportedCcIndemniteLicenciement.IDCC413:
return new Seniority413();
return new Seniority413() as ISeniority<SupportedCcIndemniteLicenciement.IDCC413>;
case SupportedCcIndemniteLicenciement.IDCC1516:
return new Seniority1516();
case SupportedCcIndemniteLicenciement.IDCC1517:
Expand All @@ -93,7 +96,7 @@ export class SeniorityFactory {
case SupportedCcIndemniteLicenciement.IDCC1606:
return new Seniority1606();
case SupportedCcIndemniteLicenciement.IDCC1672:
return new Seniority1672();
return new Seniority1672() as ISeniority<SupportedCcIndemniteLicenciement.IDCC1672>;
case SupportedCcIndemniteLicenciement.IDCC1483:
return new Seniority1483();
case SupportedCcIndemniteLicenciement.IDCC1702:
Expand All @@ -107,7 +110,7 @@ export class SeniorityFactory {
case SupportedCcIndemniteLicenciement.IDCC2120:
return new Seniority2120();
case SupportedCcIndemniteLicenciement.IDCC3248:
return new Seniority3248();
return new Seniority3248() as ISeniority<SupportedCcIndemniteLicenciement.IDCC3248>;
case SupportedCcIndemniteLicenciement.default:
default:
return new SeniorityLegal();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { accumulateAbsenceByYear, MotifKeys } from "../../common";
import { SeniorityDefault } from "../../common/seniority";

export type CC1672SeniorityProps = DefaultSeniorityProps & {
isExecutive: boolean;
isExecutive?: boolean;
becameExecutiveAt?: string;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { accumulateAbsenceByYear } from "../../common";
import { SeniorityDefault } from "../../common/seniority";

export type CC0016SeniorityProps = DefaultSeniorityProps & {
isExecutive: boolean;
isExecutive?: boolean;
becameExecutiveAt?: string;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

Expand Down Expand Up @@ -74,6 +74,11 @@ export class Seniority3248 extends SeniorityDefault<SupportedCcIndemniteLicencie
);
case "'F, G, H ou I'":
return this.computeFGHI(dateEntree, dateSortie);
case undefined: {
return {
value: 0,
};
}
}
}

Expand All @@ -98,6 +103,11 @@ export class Seniority3248 extends SeniorityDefault<SupportedCcIndemniteLicencie
);
case "'F, G, H ou I'":
return this.computeFGHI(dateEntree, dateNotification);
case undefined: {
return {
value: 0,
};
}
}
}

Expand All @@ -113,9 +123,9 @@ export class Seniority3248 extends SeniorityDefault<SupportedCcIndemniteLicencie
from: string,
to: string,
absences: Absence[],
hasBeenExecutive: boolean,
hasBeenDayContract: boolean,
dateBecomeDayContract: string | undefined
hasBeenExecutive?: boolean,
hasBeenDayContract?: boolean,
dateBecomeDayContract?: string
): SeniorityResult {
const dEntree = parseDate(from);
const dSortie = addDays(parseDate(to), 1);
Expand Down Expand Up @@ -198,9 +208,9 @@ export class Seniority3248 extends SeniorityDefault<SupportedCcIndemniteLicencie
dEntree: Date,
dSortie: Date,
absences: Absence[],
hasBeenDayContract: boolean,
hasBeenExecutive: boolean,
dateBecomeDayContract: string | undefined
hasBeenDayContract?: boolean,
hasBeenExecutive?: boolean,
dateBecomeDayContract?: string | undefined
): number {
if (!hasBeenDayContract) {
return 0;
Expand Down Expand Up @@ -233,8 +243,8 @@ export class Seniority3248 extends SeniorityDefault<SupportedCcIndemniteLicencie

private computeDateStartForDayContractIncrease(
dStart: Date,
hasBeenExecutive: boolean,
dateBecomeDayContract: string | undefined
hasBeenExecutive?: boolean,
dateBecomeDayContract?: string | undefined
): Date {
const dBecomeDayContract = dateBecomeDayContract
? parse(dateBecomeDayContract, "dd/MM/yyyy", new Date())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { accumulateAbsenceByYear } from "../../common";
import { SeniorityDefault } from "../../common/seniority";

export type CC0413SeniorityProps = DefaultSeniorityProps & {
isExecutive: boolean;
isExecutive?: boolean;
becameExecutiveAt?: string;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ import { Seniority3248 } from "../3248_metallurgie";

export type CC650SeniorityProps = DefaultSeniorityProps & {
categoriePro?: "'A, B, C, D ou E'" | "'F, G, H ou I'";
hasBeenDayContract: boolean;
hasBeenExecutive: boolean;
hasBeenDayContract?: boolean;
hasBeenExecutive?: boolean;
dateBecomeDayContract?: string;
};

export type CC650SeniorityRequiredProps = DefaultSeniorityRequiredProps & {
categoriePro?: "'A, B, C, D ou E'" | "'F, G, H ou I'";
hasBeenDayContract: boolean;
hasBeenExecutive: boolean;
hasBeenDayContract?: boolean;
hasBeenExecutive?: boolean;
dateBecomeDayContract?: string;
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import type { EvaluatedNode } from "publicodes";

import type {
RequiredSeniorityResult,
SeniorityResult,
} from "../modeles/common";
import {
IneligibilityFactory,
ReferenceSalaryFactory,
Expand Down Expand Up @@ -118,15 +114,13 @@ class IndemniteLicenciementPublicodes
return this.mapMissingArg(missingArg);
}
const agreement = new SeniorityFactory().create(this.idcc);
const agreementSeniority: SeniorityResult = agreement.computeSeniority(
const agreementSeniority = agreement.computeSeniority(
agreement.mapSituation(args)
);
const legal = new SeniorityFactory().create(
SupportedCcIndemniteLicenciement.default
);
const legalSeniority: SeniorityResult = legal.computeSeniority(
legal.mapSituation(args)
);
const legalSeniority = legal.computeSeniority(legal.mapSituation(args));
if (legalSeniority.value) {
newArgs = {
...newArgs,
Expand Down Expand Up @@ -161,15 +155,15 @@ class IndemniteLicenciementPublicodes
return this.mapMissingArg(missingArg);
}
const agreement = new SeniorityFactory().create(this.idcc);
const agreementRequiredSeniority: RequiredSeniorityResult =
agreement.computeRequiredSeniority(
agreement.mapRequiredSituation(args)
);
const agreementRequiredSeniority = agreement.computeRequiredSeniority(
agreement.mapRequiredSituation(args)
);
const legal = new SeniorityFactory().create(
SupportedCcIndemniteLicenciement.default
);
const legalRequiredSeniority: RequiredSeniorityResult =
legal.computeRequiredSeniority(legal.mapRequiredSituation(args));
const legalRequiredSeniority = legal.computeRequiredSeniority(
legal.mapRequiredSituation(args)
);
if (legalRequiredSeniority.value) {
newArgs[
"contrat salarié . indemnité de licenciement . ancienneté requise en année"
Expand Down

0 comments on commit a0105e2

Please sign in to comment.