The CP exercise (Juin N-1 → Mai N) is annual and continuous across
contract-signature changes within the same leave rule (e.g. 35h → 39h,
isDriver flip, weeklyHours bump). Capping `from` at the phase start
truncated the accrual to just the months under the latest phase,
producing wrong "en cours d'acquisition" values and dropping presence
days from earlier months on the leave-tab calendar.
For Damien GUILLOT (35h until 2025-10-31, then 39h), this gave 15 days
acquired (6 months Nov→Apr) instead of the expected 27.5 days
(11 months Jun→Apr at 2.5/month). After this fix, the H39 view shows
the full annual accrual as expected.
FORFAIT phases keep the from cap: the 218-day target is calendar-year
scoped and only counts the FORFAIT portion of the year.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Pull the "date -> leave/RTT exercise year" formula out of
EmployeeRttPaymentProcessor, EmployeeRttSummaryProvider and
EmployeeLeaveSummaryProvider into a single
App\Service\Exercise\ExerciseYearResolver. Forfait flag is parameterised
so the leave (calendar year) and RTT (Juin N-1 -> Mai N) variants share
the same implementation. Pure refactor, no behavioural change.
- Extract private helper `exerciseYearForDate(date, isForfait)` to dedupe
the date->leave-exercise-year expression duplicated across `clampYearToPhase`
and `resolveFirstComputationYear` (4 copies collapsed into 1 helper + 4
call sites).
- Remove the unused `ContractPhase $phase` parameter from
`resolveLeavePeriodBounds`: the body never reads it (the phase cap is
applied later by `resolvePeriodBounds`).
- Add `ContractNature $contractNature` to `ContractPhase` DTO, populated
from the first period of the group by `EmployeeContractPhaseResolver`.
Drop the `resolveNatureForPhase` lookup in `EmployeeLeaveSummaryProvider`
in favor of `$phase->contractNature`. Expose `contractNature` in
`Employee::getContractPhases()` array shape for frontend use.
- Fix regression for terminated employees calling `computeYearSummary`
without an explicit phase (LeaveRecapRowBuilder,
DumpVerificationSnapshotCommand). Before the refactor the period bounds,
accrual end and taken end were NOT capped at the contract end for
terminated employees, because `Employee::getCurrentContractEndDate()`
returns null when no period covers "today". The new fallback phase
(`isCurrent=false`, real `endDate`) was silently capping `to`. Add an
internal `applyPhaseEndCap` flag, true when phase is explicit, false
for legacy callers, threaded through `resolvePeriodBounds`,
`resolveAccrualCalculationEndDate` and `resolveTakenCalculationEndDate`.
- Add regression test
`testTerminatedEmployeeWithoutExplicitPhaseSkipsPhaseEndCap` proving
that legacy callers keep the natural exercise upper bound while explicit
phase callers get the cap.
- Add `contractNature` assertion in `EmployeeContractPhaseResolverTest`.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The provider now resolves a target ContractPhase from a ?phaseId query
parameter and propagates it through resolveYear, resolvePeriodBounds,
resolveLeavePolicy, resolveAccrualCalculationEndDate,
resolveTakenCalculationEndDate, and resolveFirstComputationYear.
- phaseId missing → current phase (legacy behavior preserved)
- phaseId valid → past/current phase used for rule code, weekly hours
and period bounds (capped at phase end)
- phaseId invalid (non-numeric or unknown) → 422
- year missing + phaseId → year derived from phase end date
- year out of phase range + phaseId → silent clamp to phase boundaries
Public methods computeYearSummary/resolvePaidLeaveDays/resolveLeaveYearForToday
remain backward-compatible for external callers (LeaveRecapRowBuilder,
DumpVerificationSnapshotCommand).