From 6629eb98cb85e0f759f0312ece17e6a2deafa46b Mon Sep 17 00:00:00 2001 From: tristan Date: Wed, 11 Mar 2026 11:41:26 +0100 Subject: [PATCH] =?UTF-8?q?fix=20:=20on=20ne=20prend=20plus=20en=20compte?= =?UTF-8?q?=20les=20jour=20de=20cong=C3=A9=20du=20samedi=20et=20dimanche?= =?UTF-8?q?=20pour=20les=20forfaits=20dans=20le=20calcule=20des=20RTT?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Leave/LeaveBalanceComputationService.php | 15 +++++++++++++-- src/State/EmployeeLeaveSummaryProvider.php | 17 +++++++++++++++-- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/Service/Leave/LeaveBalanceComputationService.php b/src/Service/Leave/LeaveBalanceComputationService.php index 359bd7b..1d17b6d 100644 --- a/src/Service/Leave/LeaveBalanceComputationService.php +++ b/src/Service/Leave/LeaveBalanceComputationService.php @@ -349,14 +349,25 @@ final readonly class LeaveBalanceComputationService } for ($cursor = $rangeStart; $cursor <= $rangeEnd; $cursor = $cursor->modify('+1 day')) { + $dayOfWeek = (int) $cursor->format('N'); + + if ($splitSaturdays) { + if (7 === $dayOfWeek) { + continue; + } + } else { + if ($dayOfWeek >= 6) { + continue; + } + } + [$am, $pm] = $this->resolveSegmentsForDate($absence, $cursor->format('Y-m-d')); $dayAmount = ($am ? 0.5 : 0.0) + ($pm ? 0.5 : 0.0); if ($dayAmount <= 0.0) { continue; } - $isSaturday = $splitSaturdays && '6' === $cursor->format('N'); - if ($isSaturday) { + if ($splitSaturdays && 6 === $dayOfWeek) { $takenSaturdays += $dayAmount; } else { $takenDays += $dayAmount; diff --git a/src/State/EmployeeLeaveSummaryProvider.php b/src/State/EmployeeLeaveSummaryProvider.php index 6a98f7a..7e3546d 100644 --- a/src/State/EmployeeLeaveSummaryProvider.php +++ b/src/State/EmployeeLeaveSummaryProvider.php @@ -632,14 +632,27 @@ final readonly class EmployeeLeaveSummaryProvider implements ProviderInterface } for ($cursor = $rangeStart; $cursor <= $rangeEnd; $cursor = $cursor->modify('+1 day')) { + $dayOfWeek = (int) $cursor->format('N'); + + if ($splitSaturdays) { + // Mode CDI/CDD : dimanche ignoré, samedi compté séparément. + if (7 === $dayOfWeek) { + continue; + } + } else { + // Mode forfait : seuls les jours ouvrés (lun-ven) comptent. + if ($dayOfWeek >= 6) { + continue; + } + } + [$am, $pm] = $this->resolveSegmentsForDate($absence, $cursor->format('Y-m-d')); $dayAmount = ($am ? 0.5 : 0.0) + ($pm ? 0.5 : 0.0); if ($dayAmount <= 0.0) { continue; } - $isSaturday = $splitSaturdays && '6' === $cursor->format('N'); - if ($isSaturday && $splitSaturdays) { + if ($splitSaturdays && 6 === $dayOfWeek) { $takenSaturdays += $dayAmount; } else { $takenDays += $dayAmount;