feat(leave) : show presence days in header for non-forfait, bound to contract start

Non-forfait header now shows '{weeklyHours} heures ({presence} présence)'.
Presence (presenceDaysByMonth/presenceDaysToToday) is bounded to the employee's
contract start so business days before hire are not counted (Dylan CDD: 43.5,
was 246). No change for employees present before the exercise or for forfait
(already capped at phase start). Leave summary now eager-loaded for any employee
with a leave tab to feed the header.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-21 08:14:08 +02:00
parent 03add0d45a
commit 0ad2f0c624
3 changed files with 26 additions and 10 deletions

View File

@@ -148,25 +148,31 @@ final readonly class EmployeeLeaveSummaryProvider implements ProviderInterface
);
}
// La présence est bornée au début de contrat de l'employé : on ne compte pas comme
// « présents » les jours ouvrés antérieurs à l'embauche (cas d'une entrée en cours
// d'exercice, ex. CDD). Sans effet pour un employé présent depuis avant l'exercice,
// ni pour le forfait (déjà capé au début de phase).
$presenceFrom = $this->resolveEarliestContractStartWithinRange($employee, $periodFrom, $periodTo) ?? $periodFrom;
// Forfait-only: leaves taken from N-1 stock do NOT decrement presence days.
// For non-forfait, previousYearTakenDays is always 0, so the budget has no effect.
$n1AbsencesBudget = $yearSummary['previousYearTakenDays'];
$summary->presenceDaysByMonth = $this->computePresenceDaysByMonth(
$employee,
$periodFrom,
$presenceFrom,
$periodTo,
$n1AbsencesBudget
);
// Same logic as presenceDaysByMonth but bounded at today: number of presence days
// accumulated from leave year start up to today (inclusive).
// accumulated from contract start up to today (inclusive).
$today = new DateTimeImmutable('today');
$cappedTo = $today < $periodTo ? $today : $periodTo;
$summary->presenceDaysToToday = $today < $periodFrom
$summary->presenceDaysToToday = $today < $presenceFrom
? 0.0
: array_sum($this->computePresenceDaysByMonth(
$employee,
$periodFrom,
$presenceFrom,
$cappedTo,
$n1AbsencesBudget
));