-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(indemnite-licenciement): retours de la cc 1516 (#5392)
- Loading branch information
Showing
4 changed files
with
135 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
...conventions/1516_organismes_formation/__tests__/indemnite-licenciement/anciennete.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { | ||
MotifKeys, | ||
SeniorityFactory, | ||
SupportedCcIndemniteLicenciement, | ||
} from "../../../../common"; | ||
|
||
describe("CC 1516", () => { | ||
describe("Calcul de l'ancienneté", () => { | ||
test.each` | ||
absences | entryDate | exitDate | expectedAnciennete | ||
${[]} | ${"01/01/2020"} | ${"01/01/2021"} | ${1} | ||
${[{ motif: { key: MotifKeys.maladieNonPro } }, { motif: { key: MotifKeys.accidentTrajet } }, { motif: { key: MotifKeys.congesSabbatique } }, { motif: { key: MotifKeys.congesCreationEntreprise } }, { motif: { key: MotifKeys.congesParentalEducation } }, { motif: { key: MotifKeys.congesSansSolde } }, { motif: { key: MotifKeys.greve } }, { motif: { key: MotifKeys.miseAPied } }]} | ${"20/03/2020"} | ${"20/03/2021"} | ${1} | ||
${[{ durationInMonth: "1", motif: { key: MotifKeys.maladieNonPro } }, { durationInMonth: "1", motif: { key: MotifKeys.accidentTrajet } }, { durationInMonth: "1", motif: { key: MotifKeys.congesSabbatique } }, { durationInMonth: "1", motif: { key: MotifKeys.congesCreationEntreprise } }, { durationInMonth: "1", motif: { key: MotifKeys.congesParentalEducation } }, { durationInMonth: "1", motif: { key: MotifKeys.congesSansSolde } }, { durationInMonth: "1", motif: { key: MotifKeys.greve } }, { durationInMonth: "1", motif: { key: MotifKeys.miseAPied } }]} | ${"01/01/2000"} | ${"01/01/2023"} | ${22.416666666666668} | ||
${[{ durationInMonth: "1", motif: { key: MotifKeys.maladieNonPro } }, { durationInMonth: "1", motif: { key: MotifKeys.accidentTrajet } }, { durationInMonth: "1", motif: { key: MotifKeys.congesSabbatique } }, { durationInMonth: "1", motif: { key: MotifKeys.congesCreationEntreprise } }, { durationInMonth: "35", motif: { key: MotifKeys.congesParentalEducation } }, { durationInMonth: "1", motif: { key: MotifKeys.congesSansSolde } }, { durationInMonth: "1", motif: { key: MotifKeys.greve } }, { durationInMonth: "1", motif: { key: MotifKeys.miseAPied } }]} | ${"01/01/2000"} | ${"01/01/2023"} | ${22.416666666666668} | ||
${[{ durationInMonth: "1", motif: { key: MotifKeys.maladieNonPro } }, { durationInMonth: "1", motif: { key: MotifKeys.accidentTrajet } }, { durationInMonth: "1", motif: { key: MotifKeys.congesSabbatique } }, { durationInMonth: "1", motif: { key: MotifKeys.congesCreationEntreprise } }, { durationInMonth: "36", motif: { key: MotifKeys.congesParentalEducation } }, { durationInMonth: "1", motif: { key: MotifKeys.congesSansSolde } }, { durationInMonth: "1", motif: { key: MotifKeys.greve } }, { durationInMonth: "1", motif: { key: MotifKeys.miseAPied } }]} | ${"01/01/2000"} | ${"01/01/2023"} | ${22.416666666666668} | ||
${[{ durationInMonth: "1", motif: { key: MotifKeys.maladieNonPro } }, { durationInMonth: "1", motif: { key: MotifKeys.accidentTrajet } }, { durationInMonth: "1", motif: { key: MotifKeys.congesSabbatique } }, { durationInMonth: "1", motif: { key: MotifKeys.congesCreationEntreprise } }, { durationInMonth: "18", motif: { key: MotifKeys.congesParentalEducation } }, { durationInMonth: "18", motif: { key: MotifKeys.congesParentalEducation } }, { durationInMonth: "1", motif: { key: MotifKeys.congesSansSolde } }, { durationInMonth: "1", motif: { key: MotifKeys.greve } }, { durationInMonth: "1", motif: { key: MotifKeys.miseAPied } }]} | ${"01/01/2000"} | ${"01/01/2023"} | ${22.416666666666668} | ||
${[{ durationInMonth: "1", motif: { key: MotifKeys.maladieNonPro } }, { durationInMonth: "1", motif: { key: MotifKeys.accidentTrajet } }, { durationInMonth: "1", motif: { key: MotifKeys.congesSabbatique } }, { durationInMonth: "1", motif: { key: MotifKeys.congesCreationEntreprise } }, { durationInMonth: "37", motif: { key: MotifKeys.congesParentalEducation } }, { durationInMonth: "1", motif: { key: MotifKeys.congesSansSolde } }, { durationInMonth: "1", motif: { key: MotifKeys.greve } }, { durationInMonth: "1", motif: { key: MotifKeys.miseAPied } }]} | ${"01/01/2000"} | ${"01/01/2023"} | ${22.375} | ||
${[{ durationInMonth: "1", motif: { key: MotifKeys.maladieNonPro } }, { durationInMonth: "1", motif: { key: MotifKeys.accidentTrajet } }, { durationInMonth: "1", motif: { key: MotifKeys.congesSabbatique } }, { durationInMonth: "1", motif: { key: MotifKeys.congesCreationEntreprise } }, { durationInMonth: "18", motif: { key: MotifKeys.congesParentalEducation } }, { durationInMonth: "19", motif: { key: MotifKeys.congesParentalEducation } }, { durationInMonth: "1", motif: { key: MotifKeys.congesSansSolde } }, { durationInMonth: "1", motif: { key: MotifKeys.greve } }, { durationInMonth: "1", motif: { key: MotifKeys.miseAPied } }]} | ${"01/01/2000"} | ${"01/01/2023"} | ${22.375} | ||
`( | ||
"Calcul de l'ancienneté avec $entryDate et $exitDate en attendant $expectedAnciennete an", | ||
({ absences, entryDate, exitDate, expectedAnciennete }) => { | ||
const seniority = new SeniorityFactory().create( | ||
SupportedCcIndemniteLicenciement.IDCC1516 | ||
); | ||
|
||
const result = seniority.computeSeniority({ | ||
absencePeriods: absences, | ||
dateEntree: entryDate, | ||
dateSortie: exitDate, | ||
}); | ||
|
||
expect(result.value).toEqual(expectedAnciennete); | ||
} | ||
); | ||
}); | ||
}); |
1 change: 1 addition & 0 deletions
1
packages/code-du-travail-modeles/src/modeles/conventions/1516_organismes_formation/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from "./salary"; | ||
export * from "./seniority"; |
95 changes: 95 additions & 0 deletions
95
...es/code-du-travail-modeles/src/modeles/conventions/1516_organismes_formation/seniority.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
import { addDays, differenceInMonths } from "date-fns"; | ||
|
||
import { LEGAL_MOTIFS } from "../../base"; | ||
import type { | ||
Absence, | ||
DefaultSeniorityRequiredProps, | ||
ISeniority, | ||
Motif, | ||
RequiredSeniorityResult, | ||
SeniorityProps, | ||
SeniorityResult, | ||
SupportedCcIndemniteLicenciement, | ||
} from "../../common"; | ||
import { MotifKeys, parseDate } from "../../common"; | ||
|
||
export class Seniority1516 | ||
implements ISeniority<SupportedCcIndemniteLicenciement.IDCC1516> | ||
{ | ||
getMotifs(): Motif[] { | ||
return LEGAL_MOTIFS; | ||
} | ||
|
||
computeSeniority({ | ||
dateEntree, | ||
dateSortie, | ||
absencePeriods = [], | ||
}: SeniorityProps<SupportedCcIndemniteLicenciement.IDCC1516>): SeniorityResult { | ||
return this.compute(dateEntree, dateSortie, absencePeriods); | ||
} | ||
|
||
computeRequiredSeniority({ | ||
dateEntree, | ||
dateNotification, | ||
absencePeriods = [], | ||
}: DefaultSeniorityRequiredProps): RequiredSeniorityResult { | ||
return this.compute(dateEntree, dateNotification, absencePeriods); | ||
} | ||
|
||
protected compute( | ||
from: string, | ||
to: string, | ||
absences: Absence[] | ||
): SeniorityResult { | ||
const dEntree = parseDate(from); | ||
const dSortie = addDays(parseDate(to), 1); | ||
const MAXIMUM_CONGES_PARENTAL_EN_MOIS = 36; | ||
const totalAbsenceSansCongesParental = absences | ||
.filter((period) => Boolean(period.durationInMonth)) | ||
.reduce((total, item) => { | ||
const m = this.getMotifs().find( | ||
(motif) => motif.key === item.motif.key | ||
); | ||
if ( | ||
!m || | ||
!item.durationInMonth || | ||
m.key === MotifKeys.congesParentalEducation | ||
) { | ||
return total; | ||
} | ||
return total + item.durationInMonth * m.value; | ||
}, 0); | ||
const totalAbsenceAvecCongesParentalSansCoeff = absences | ||
.filter((period) => Boolean(period.durationInMonth)) | ||
.reduce((total, item: any) => { | ||
const m = this.getMotifs().find( | ||
(motif) => motif.key === item.motif.key | ||
); | ||
if ( | ||
!m || | ||
!item.durationInMonth || | ||
m.key !== MotifKeys.congesParentalEducation | ||
) { | ||
return total; | ||
} | ||
return total + parseInt(item.durationInMonth); | ||
}, 0); | ||
const congesMotif = this.getMotifs().find( | ||
(motif) => motif.key === MotifKeys.congesParentalEducation | ||
); | ||
if (!congesMotif) { | ||
throw new Error("Motif congé parental non trouvé"); | ||
} | ||
|
||
const totalCongesParental = | ||
totalAbsenceAvecCongesParentalSansCoeff >= MAXIMUM_CONGES_PARENTAL_EN_MOIS | ||
? (totalAbsenceAvecCongesParentalSansCoeff - | ||
MAXIMUM_CONGES_PARENTAL_EN_MOIS) * | ||
congesMotif.value | ||
: 0; | ||
const totalAbsence = totalCongesParental + totalAbsenceSansCongesParental; | ||
return { | ||
value: (differenceInMonths(dSortie, dEntree) - totalAbsence) / 12, | ||
}; | ||
} | ||
} |