feat(absences) : mise en conformité légale (événements familiaux, demi-journée, CCN)

Périmètre 1-6 du design 2026-05-22-absence-legal-compliance-fixes (points
lourds — ancienneté, CP pendant maladie, rétention — reportés en backlog).

- Événements familiaux sans solde : AbsenceType::decrementsBalance() ne vaut
  true que pour les CP. Mariage/PACS, naissance, décès = droits par événement ;
  congé parental = suspension ; maladie = Sécu. Plus de solde fantôme.
- Décès : daysPerEvent = null (selon lien de parenté) + motif obligatoire à la
  création (REST + MCP), les minimums légaux étant rappelés dans l'aide.
- Ajout du congé naissance (type, policy 3 j, justificatif, libellés/couleur front).
- Garde-fou demi-journée : -0,5 appliqué uniquement si le jour-borne est
  réellement décompté (corrige un sous-décompte week-end/férié) — TDD.
- CCN documentée : paramètre app.absence.convention = "Syntec (IDCC 1486)",
  rappelée en sous-titre admin et dans l'aide /help.

Tests : AbsenceDayCalculatorTest (garde-fou demi-journée), AbsenceRequestLifecycle
(motif décès obligatoire + aucun solde touché). make test 52/52, build Nuxt OK.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Matthieu
2026-05-22 16:00:28 +02:00
parent e9aaccc62c
commit f9773b3a5e
12 changed files with 123 additions and 25 deletions
+21 -14
View File
@@ -42,32 +42,39 @@ final readonly class AbsenceDayCalculator
$period = new DatePeriod($start, new DateInterval('P1D'), $end->modify('+1 day'));
foreach ($period as $day) {
$weekday = (int) $day->format('N'); // 1 (Mon) .. 7 (Sun)
if (7 === $weekday) {
continue; // Sunday: never counted
if ($this->isCountedDay($day, $workingDaysOnly)) {
++$days;
}
if (6 === $weekday && $workingDaysOnly) {
continue; // Saturday: only counted for "jours ouvrables"
}
if ($this->holidayProvider->isHoliday($day)) {
continue;
}
++$days;
}
if ($days <= 0.0) {
return 0.0;
}
if (null !== $startHalfDay) {
// A half-day only subtracts 0.5 when its boundary day is actually
// counted (otherwise a half-day posted on a weekend/holiday would
// wrongly under-count the absence).
if (null !== $startHalfDay && $this->isCountedDay($start, $workingDaysOnly)) {
$days -= 0.5;
}
if (null !== $endHalfDay) {
if (null !== $endHalfDay && $this->isCountedDay($end, $workingDaysOnly)) {
$days -= 0.5;
}
return max(0.0, $days);
}
private function isCountedDay(DateTimeImmutable $day, bool $workingDaysOnly): bool
{
$weekday = (int) $day->format('N'); // 1 (Mon) .. 7 (Sun)
if (7 === $weekday) {
return false; // Sunday: never counted
}
if (6 === $weekday && $workingDaysOnly) {
return false; // Saturday: only counted for "jours ouvrables"
}
return !$this->holidayProvider->isHoliday($day);
}
}