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;