Skip to content

Commit

Permalink
feat: indemnite licenciement 1404 (#5133)
Browse files Browse the repository at this point in the history
* feat: prendre referer au lieu de src_url

* Revert "feat: prendre referer au lieu de src_url"

This reverts commit 5516d3c.

* feat: implement indemnite licenciement CC1404

* fix: affichage input mobile

* chore: fix tests

* fix: reviews

* fix: seniority 1404

* chore: fix test

* fix: missed copy

* chore: snap

* fix: wording + seniority

* chore: review

* fix: changement metier

* fix: review

* chore: update snap

* feat: ajout des descriptions pour salaires

* fix: cadre bleu qui ne s'affiche plus

* fix: seniorirt

* chore: snap

* fix: test

---------

Co-authored-by: Victor Zeinstra <[email protected]>
Co-authored-by: Martial Maillot <[email protected]>
  • Loading branch information
3 people authored Jun 20, 2023
1 parent c0226db commit 5fa2153
Show file tree
Hide file tree
Showing 26 changed files with 1,246 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const PubliQuestion: React.FC<Props> = ({
// to avoid collision with other components for YesNoQuestion
Math.random().toString(36).substring(2, 15)
);
const { question, titre, cdtn } = rule;
const { question, titre, cdtn, unité } = rule;
const tooltip = rule.description
? {
content: <Html>{rule.description}</Html>,
Expand Down Expand Up @@ -99,7 +99,7 @@ const PubliQuestion: React.FC<Props> = ({
error={error}
id={name}
showRequired
icon={icons.Euro}
icon={unité === "€" ? icons.Euro : undefined}
subLabel={cdtn.precision}
dataTestId={name}
/>
Expand Down Expand Up @@ -127,6 +127,7 @@ const PubliQuestion: React.FC<Props> = ({
inputType="number"
value={value}
onChange={onChange}
text={unité}
error={error}
id={name}
showRequired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,18 +187,24 @@ const createCommonInformationsStore: StoreSlice<
const agreement = get().agreementData.input.agreement!;
let isStepHidden = false;
if (
agreement &&
agreement.num === 3239 &&
publicodesInformations.find(
(v) =>
v.question.rule.nom ===
"contrat salarié . convention collective . particuliers employeurs et emploi à domicile . indemnité de licenciement . catégorie professionnelle"
)?.info === `'${CatPro3239.assistantMaternel}'` &&
publicodesInformations.find(
(v) =>
v.question.rule.nom ===
"contrat salarié . convention collective . particuliers employeurs et emploi à domicile . indemnité de licenciement . catégorie professionnelle . assistante maternelle . type de licenciement"
)?.info === `'Non'`
(agreement &&
agreement.num === 3239 &&
publicodesInformations.find(
(v) =>
v.question.rule.nom ===
"contrat salarié . convention collective . particuliers employeurs et emploi à domicile . indemnité de licenciement . catégorie professionnelle"
)?.info === `'${CatPro3239.assistantMaternel}'` &&
publicodesInformations.find(
(v) =>
v.question.rule.nom ===
"contrat salarié . convention collective . particuliers employeurs et emploi à domicile . indemnité de licenciement . catégorie professionnelle . assistante maternelle . type de licenciement"
)?.info === `'Non'`) ||
(agreement.num === 1404 &&
publicodesInformations.find(
(v) =>
v.question.rule.nom ===
"contrat salarié . convention collective . sedima . question cdi opération"
)?.info === `'Oui'`)
) {
isStepHidden = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type Props = {
icon?: FunctionComponent;
id: string;
dataTestId?: string;
text?: string;
};

export default function TextQuestion({
Expand All @@ -39,6 +40,7 @@ export default function TextQuestion({
icon,
id,
dataTestId,
text,
}: Props) {
const InputComponent = inputType === "date" ? InputDate : Input;
return (
Expand All @@ -57,6 +59,7 @@ export default function TextQuestion({
invalid={!!error}
placeholder={placeholder}
icon={icon}
text={text}
type={inputType === "date" ? "text" : inputType}
updateOnScrollDisabled
data-testid={dataTestId}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
import { render, fireEvent } from "@testing-library/react";
import React from "react";
import { CalculateurIndemnite } from "../../../../src/outils";
import { ui } from "./ui";
import userEvent from "@testing-library/user-event";

jest.spyOn(Storage.prototype, "setItem");
Storage.prototype.getItem = jest.fn(
() => `{
"url":"https://www.legifrance.gouv.fr/affichIDCC.do?idConvention=KALICONT000005635653",
"id":"KALICONT000005635653",
"num":1404,
"shortTitle":"Entreprises de la maintenance, distribution et location de matériels agricoles, de travaux publics, de bâtiment, de manutention, de motoculture de plaisance et activités connexes, dite SDLM",
"slug":"1404-entreprises-de-la-maintenance-distribution-et-location-de-materiels-agrico",
"title":"Entreprises de la maintenance, distribution et location de matériels agricoles, de travaux publics, de bâtiment, de manutention, de motoculture de plaisance et activités connexes, dite SDLM"
}`
);

describe("Indemnité licenciement - CC 1404", () => {
beforeEach(() => {
render(
<CalculateurIndemnite
icon={""}
title={""}
displayTitle={""}
slug={"indemnite-licenciement"}
/>
);
userEvent.click(ui.introduction.startButton.get());
userEvent.click(ui.contract.type.cdi.get());
userEvent.click(ui.contract.fauteGrave.non.get());
userEvent.click(ui.contract.inaptitude.non.get());
userEvent.click(ui.contract.arretTravail.non.get());
userEvent.click(ui.next.get());
userEvent.click(ui.next.get());
});

test("Vérifier que le CDI classique amène au résultat", () => {
userEvent.click(ui.information.agreement1404.cdiOperation.non.get());
userEvent.click(ui.next.get());
fireEvent.change(ui.seniority.startDate.get(), {
target: { value: "01/01/2000" },
});
fireEvent.change(ui.seniority.notificationDate.get(), {
target: { value: "01/01/2022" },
});
fireEvent.change(ui.seniority.endDate.get(), {
target: { value: "01/03/2022" },
});
fireEvent.click(ui.seniority.hasAbsence.non.get());
fireEvent.click(ui.next.get());
fireEvent.click(ui.salary.hasPartialTime.non.get());
fireEvent.click(ui.salary.hasSameSalary.oui.get());
fireEvent.change(ui.salary.sameSalaryValue.get(), {
target: { value: "3000" },
});
fireEvent.click(ui.next.get());
expect(ui.activeStep.query()).toHaveTextContent("Indemnité");
});
describe("Etant donné un CDI opération", () => {
beforeEach(() =>
userEvent.click(ui.information.agreement1404.cdiOperation.oui.get())
);
describe("Etant donné une ancienneté < 6 mois", () => {
beforeEach(() =>
fireEvent.change(ui.information.agreement1404.duree.get(), {
target: { value: "5" },
})
);
test("Vérifier que le licenciement avant fin de la période d'essai amène au résultat", () => {
userEvent.click(ui.information.agreement1404.trial.oui.get());
userEvent.click(ui.next.get());
fireEvent.change(ui.seniority.startDate.get(), {
target: { value: "01/01/2022" },
});
fireEvent.change(ui.seniority.notificationDate.get(), {
target: { value: "01/04/2022" },
});
fireEvent.change(ui.seniority.endDate.get(), {
target: { value: "01/05/2022" },
});
fireEvent.click(ui.seniority.hasAbsence.non.get());
fireEvent.click(ui.next.get());
expect(ui.activeStep.query()).toHaveTextContent("Indemnité");
});
test("Vérifier que le licenciement après fin de la période d'essai amène au résultat", () => {
userEvent.click(ui.information.agreement1404.trial.non.get());
fireEvent.change(ui.information.agreement1404.salaryTotal.get(), {
target: { value: "50000" },
});
userEvent.click(ui.next.get());
fireEvent.change(ui.seniority.startDate.get(), {
target: { value: "01/01/2022" },
});
fireEvent.change(ui.seniority.notificationDate.get(), {
target: { value: "01/04/2022" },
});
fireEvent.change(ui.seniority.endDate.get(), {
target: { value: "01/05/2022" },
});
fireEvent.click(ui.seniority.hasAbsence.non.get());
fireEvent.click(ui.next.get());
expect(ui.activeStep.query()).toHaveTextContent("Indemnité");
});
});
test("Vérifier qu'avec plus de 6 mois on arrive au résultat", () => {
fireEvent.change(ui.information.agreement1404.duree.get(), {
target: { value: "30" },
});
fireEvent.change(ui.information.agreement1404.salary1.get(), {
target: { value: "100000" },
});
fireEvent.change(ui.information.agreement1404.salary2.get(), {
target: { value: "150000" },
});
fireEvent.change(ui.information.agreement1404.salary3.get(), {
target: { value: "200000" },
});
userEvent.click(ui.next.get());
fireEvent.change(ui.seniority.startDate.get(), {
target: { value: "01/01/2000" },
});
fireEvent.change(ui.seniority.notificationDate.get(), {
target: { value: "01/01/2022" },
});
fireEvent.change(ui.seniority.endDate.get(), {
target: { value: "01/03/2022" },
});
fireEvent.click(ui.seniority.hasAbsence.non.get());
fireEvent.click(ui.next.get());
expect(ui.activeStep.query()).toHaveTextContent("Indemnité");
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,39 @@ export const ui = {
"infos.contrat salarié - convention collective - coiffure - indemnité de licenciement - catégorie professionnelle"
),
},
agreement1404: {
cdiOperation: {
oui: byTestId(
"infos.contrat salarié - convention collective - sedima - question cdi opération - Oui"
),
non: byTestId(
"infos.contrat salarié - convention collective - sedima - question cdi opération - Non"
),
},
duree: byTestId(
"infos.contrat salarié - convention collective - sedima - cdi opération - durée"
),
salary1: byTestId(
"infos.contrat salarié - convention collective - sedima - cdi opération - plus de 6 mois - salaires 1e année"
),
salary2: byTestId(
"infos.contrat salarié - convention collective - sedima - cdi opération - plus de 6 mois - salaires 2e année"
),
salary3: byTestId(
"infos.contrat salarié - convention collective - sedima - cdi opération - plus de 6 mois - salaires 3e année et plus"
),
trial: {
oui: byTestId(
"infos.contrat salarié - convention collective - sedima - cdi opération - moins de 6 mois - question période essai - Oui"
),
non: byTestId(
"infos.contrat salarié - convention collective - sedima - cdi opération - moins de 6 mois - question période essai - Non"
),
},
salaryTotal: byTestId(
"infos.contrat salarié - convention collective - sedima - cdi opération - moins de 6 mois - salaires total"
),
},
agreement2148: {
age: byTestId(
"infos.contrat salarié - convention collective - télécommunications - age"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const hasNoBetterAllowance = (ccn: number): boolean => ccn === 3239;

export default hasNoBetterAllowance;
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
const hasNoLegalIndemnity = (ccn: number): boolean => ccn === 3239;
import { AgreementInformation } from "../types";

const hasNoLegalIndemnity = (
ccn: number,
agreementInformations?: AgreementInformation[]
): boolean =>
ccn === 3239 ||
(ccn === 1404 &&
!!agreementInformations?.some(
({ label, value }) => label === "CDI d'opération" && value === "'Oui'"
));

export default hasNoLegalIndemnity;
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export { default as computeSalaryPeriods } from "./computeSalaryPeriods";
export { default as getSupportedCcIndemniteLicenciement } from "./getSupportedCc";
export { default as hasNoLegalIndemnity } from "./hasNoLegalIndemnity";
export { default as isCcFullySupportedIndemniteLicenciement } from "./isCcFullySupported";
export { default as hasNoBetterAllowance } from "./hasNoBetterAllowance";
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@ export const getErrorEligibility = (
minimalSeniorityInMonth = 0;
}
break;
case 1404:
requiredSeniorityInYear = requiredSeniorityAgreement;
if (
stateInfo.publicodesInformations?.length > 0 &&
stateInfo.publicodesInformations[0]?.info === "'Oui'" // CDI d'opération
) {
minimalSeniorityInMonth = 0;
}
break;
}
const isEligible = requiredSeniorityInYear >= minimalSeniorityInMonth / 12;
return !isEligible ? minimalSeniorityError : undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export default function Eligible() {
hasSameSalary,
notifications,
agreementHasNoLegalIndemnity,
agreementHasNoBetterAllowance,
isStepSalaryHidden,
infoWarning,
dateArretTravail,
Expand Down Expand Up @@ -82,6 +83,8 @@ export default function Eligible() {
notifications: state.resultData.input.notifications,
agreementHasNoLegalIndemnity:
state.resultData.input.agreementHasNoLegalIndemnity,
agreementHasNoBetterAllowance:
state.resultData.input.agreementHasNoBetterAllowance,
isStepSalaryHidden: state.informationsData.input.isStepSalaryHidden,
infoWarning: state.resultData.input.infoWarning,
dateArretTravail: state.contratTravailData.input.dateArretTravail,
Expand Down Expand Up @@ -162,7 +165,7 @@ export default function Eligible() {
}
/>
</ShowDetails>
{!agreementHasNoLegalIndemnity && infoWarning && (
{!agreementHasNoBetterAllowance && infoWarning && (
<Disclaimer
title={infoWarning.title}
dataTestId="eligible-cc-disclaimer"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ import {
getAgreementReferenceSalary,
} from "../../../agreements";
import { isParentalNoticeHiddenForAgreement } from "../../../agreements/ui-customizations/messages";
import { AgreementInformation, hasNoLegalIndemnity } from "../../../common";
import {
AgreementInformation,
hasNoLegalIndemnity,
hasNoBetterAllowance,
} from "../../../common";
import { MainStore } from "../../../store";
import { StoreApi } from "zustand";
import {
Expand Down Expand Up @@ -204,6 +208,7 @@ const createResultStore: StoreSlice<
let agreementNotifications: Notification[] = [];
let notifications: Notification[];
let agreementHasNoLegalIndemnity: boolean;
let agreementHasNoBetterAllowance: boolean;
let agreementSalaryExtraInfo: Record<string, string | number> = {};
let isParentalNoticeHidden = false;

Expand Down Expand Up @@ -269,7 +274,12 @@ const createResultStore: StoreSlice<

agreementNotifications = publicodes.getNotifications();

agreementHasNoLegalIndemnity = hasNoLegalIndemnity(agreement.num);
agreementHasNoLegalIndemnity = hasNoLegalIndemnity(
agreement.num,
agreementInformations
);

agreementHasNoBetterAllowance = hasNoBetterAllowance(agreement.num);

isParentalNoticeHidden = isParentalNoticeHiddenForAgreement(
agreement.num
Expand Down Expand Up @@ -326,6 +336,8 @@ const createResultStore: StoreSlice<
state.resultData.input.notifications = notifications;
state.resultData.input.agreementHasNoLegalIndemnity =
agreementHasNoLegalIndemnity;
state.resultData.input.agreementHasNoBetterAllowance =
agreementHasNoBetterAllowance;
state.resultData.input.isParentalNoticeHidden =
isParentalNoticeHidden;
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export type ResultStoreInput = {
agreementInformations?: AgreementInformation[];
notifications?: Notification[];
agreementHasNoLegalIndemnity?: boolean;
agreementHasNoBetterAllowance?: boolean;
isEligible: boolean;
infoWarning?: { message: string; title: string };
isParentalNoticeHidden: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ exports[`<Salaires /> should add a salaire 1`] = `
value=""
/>
<div
class="sc-iEXKAA jqdzTX"
class="sc-iEXKAA dVguAh"
>
<svg
aria-hidden="true"
Expand Down Expand Up @@ -180,7 +180,7 @@ exports[`<Salaires /> should render 1`] = `
value="3000"
/>
<div
class="sc-iEXKAA jqdzTX"
class="sc-iEXKAA dVguAh"
>
<svg
aria-hidden="true"
Expand Down
Loading

0 comments on commit 5fa2153

Please sign in to comment.