feat(leave) : align forfait CP N + display remaining workdays + N-1 absences exempt from presence
- LeaveRecapRowBuilder: forfait CP N now reflects remainingDays (acquis − pris depuis N) instead of the constant acquiredDays. Affects both PDF export and screen recap. - Employee detail header: forfait label becomes "Forfait - 218 jours (X restants)" where X = 218 − presence days from Jan 1 to today (today included). - New EmployeeLeaveSummary.presenceDaysToToday field, computed via the same logic as presenceDaysByMonth but capped at today. - Forfait business rule: leaves attributed to N-1 stock no longer decrement presence days. Implemented by chronologically consuming an N-1 budget (= previousYearTakenDays) inside computePresenceDaysByMonth before counting any absence. Non-forfait unaffected (budget is 0). - Doc updates: CLAUDE.md (forfait/N-1 rule), functional-rules.md (CP N forfait semantics). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -61,6 +61,7 @@
|
||||
- INTERIM: no overtime bonuses, no recovery time
|
||||
- Driver contracts: RTT uses `dayHoursMinutes + nightHoursMinutes + workshopHoursMinutes` instead of morning/afternoon/evening time ranges
|
||||
- FORFAIT weekend/holiday bonus: each weekend or public holiday day worked gives bonus leave (full day if morning+afternoon, 0.5 if only one). Added to acquired days, no cap. PRESENCE mode only.
|
||||
- **FORFAIT — jours de présence et N-1** : les congés posés et imputés sur le stock N-1 ne décrémentent **pas** les jours de présence affichés (`presenceDaysByMonth` et `presenceDaysToToday`). Implémenté dans `EmployeeLeaveSummaryProvider::computePresenceDaysByMonth` via un budget N-1 (= `previousYearTakenDays`) consommé chronologiquement avant comptage des absences. Pour les non-forfait, ce budget vaut toujours 0 → comportement inchangé.
|
||||
|
||||
## Récap. congés (écran)
|
||||
- Accès via sidebar `Récap. congés`, conditionné au flag `User.hasLeaveRecapAccess` (défaut `false`) — activé au create/edit user. Le flag s'applique à tous les profils, y compris admin.
|
||||
|
||||
@@ -335,7 +335,7 @@ Tous les filtres checkbox sont cochés par défaut à l'ouverture du drawer.
|
||||
| Contrat | Contract.name |
|
||||
| CP N-1 restant | CDI/CDD: acquis N-1 − pris sur N-1. Forfait: report N-1 restant |
|
||||
| Samedi restant | CDI/CDD: samedis acquis N-1 − pris. Forfait: `-` |
|
||||
| CP N | Forfait: jours acquis année civile. Non-forfait: en cours d'acquisition |
|
||||
| CP N | Forfait: restant sur quota année civile (acquis − pris depuis N, sans toucher au stock N-1). Non-forfait: en cours d'acquisition |
|
||||
| RTT | Minutes disponibles (report N-1 + acquis N - payés). Format `X h Y m`. Forfait et INTERIM: `-` |
|
||||
|
||||
## 10bis) Écran Récap. congés (tableau)
|
||||
|
||||
@@ -10,10 +10,11 @@ export const useEmployeeDetailPage = () => {
|
||||
|
||||
const showLeaveTab = computed(() => employee.value?.currentContractNature !== 'INTERIM')
|
||||
const showRttTab = computed(() => employee.value?.contract?.type !== CONTRACT_TYPES.FORFAIT)
|
||||
const isForfait = computed(() => employee.value?.contract?.type === CONTRACT_TYPES.FORFAIT)
|
||||
const employeeContractWorkLabel = computed(() => {
|
||||
const contract = employee.value?.contract
|
||||
if (!contract) return '-'
|
||||
if (contract.type === CONTRACT_TYPES.FORFAIT) return 'Forfait'
|
||||
if (contract.type === CONTRACT_TYPES.FORFAIT) return 'Forfait - 218 jours'
|
||||
if (contract.weeklyHours !== null && contract.weeklyHours !== undefined) return `${contract.weeklyHours} heures`
|
||||
return contract.name || '-'
|
||||
})
|
||||
@@ -55,6 +56,9 @@ export const useEmployeeDetailPage = () => {
|
||||
await bonus.loadBonusData()
|
||||
} else if (activeTab.value === 'observation') {
|
||||
await observation.loadObservationData()
|
||||
} else if (isForfait.value && showLeaveTab.value) {
|
||||
// Eager load: needed for the "X jours restants" header label on forfait employees.
|
||||
await leave.loadLeaveData()
|
||||
}
|
||||
} finally {
|
||||
isLoading.value = false
|
||||
@@ -63,6 +67,13 @@ export const useEmployeeDetailPage = () => {
|
||||
|
||||
const contract = useEmployeeContract(employee, loadEmployee)
|
||||
const leave = useEmployeeLeave(employee, loadEmployee)
|
||||
const forfaitRemainingDaysLabel = computed(() => {
|
||||
if (!isForfait.value) return ''
|
||||
const presence = leave.leaveSummary.value?.presenceDaysToToday
|
||||
if (presence === undefined || presence === null) return ''
|
||||
const remaining = 218 - presence
|
||||
return ` (${remaining} restants)`
|
||||
})
|
||||
const rtt = useEmployeeRtt(employee, loadEmployee)
|
||||
const mileage = useEmployeeMileage(employee, loadEmployee)
|
||||
const formation = useEmployeeFormation(employee, loadEmployee)
|
||||
@@ -97,6 +108,7 @@ export const useEmployeeDetailPage = () => {
|
||||
showLeaveTab,
|
||||
showRttTab,
|
||||
employeeContractWorkLabel,
|
||||
forfaitRemainingDaysLabel,
|
||||
...contract,
|
||||
...leave,
|
||||
...rtt,
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<p>Date d'entrée : {{ employee.entryDate ? employee.entryDate.split('-').reverse().join('/') : '-' }}</p>
|
||||
</div>
|
||||
<div class="text-right">
|
||||
<p class="font-bold text-[22px]">{{ contractNatureLabel(employee.currentContractNature) }} {{ employeeContractWorkLabel }}</p>
|
||||
<p class="font-bold text-[22px]">{{ contractNatureLabel(employee.currentContractNature) }} {{ employeeContractWorkLabel }}{{ forfaitRemainingDaysLabel }}</p>
|
||||
<p class="text-[18px]">{{ employee.site?.name ?? '-' }}</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -257,6 +257,7 @@ const {
|
||||
showRttTab,
|
||||
contractHistory,
|
||||
employeeContractWorkLabel,
|
||||
forfaitRemainingDaysLabel,
|
||||
contractForm,
|
||||
createContractForm,
|
||||
isContractDrawerOpen,
|
||||
|
||||
@@ -15,5 +15,6 @@ export type EmployeeLeaveSummary = {
|
||||
previousYearRemainingDays: number
|
||||
previousYearPaidDays: number
|
||||
presenceDaysByMonth: Record<string, number>
|
||||
presenceDaysToToday: number
|
||||
}
|
||||
|
||||
|
||||
@@ -38,4 +38,7 @@ final class EmployeeLeaveSummary
|
||||
|
||||
/** @var array<string, float> YYYY-MM => count (0.5 for half-days) */
|
||||
public array $presenceDaysByMonth = [];
|
||||
|
||||
/** Cumul des jours de présence depuis le début de l'année de congé jusqu'à aujourd'hui (forfait). */
|
||||
public float $presenceDaysToToday = 0.0;
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ final readonly class LeaveRecapRowBuilder
|
||||
}
|
||||
}
|
||||
$cpN1Remaining = round($yearSummary['previousYearRemainingDays'], 2);
|
||||
$cpN = (string) round($yearSummary['acquiredDays'], 2);
|
||||
$cpN = (string) round($yearSummary['remainingDays'], 2);
|
||||
$acquiredSaturdays = '-';
|
||||
} else {
|
||||
$cpN1Remaining = round($yearSummary['remainingDays'], 2);
|
||||
|
||||
@@ -119,8 +119,29 @@ final readonly class EmployeeLeaveSummaryProvider implements ProviderInterface
|
||||
$summary->previousYearRemainingDays = $yearSummary['previousYearRemainingDays'];
|
||||
$summary->previousYearPaidDays = $paidLeaveDays;
|
||||
|
||||
[$periodFrom, $periodTo] = $this->resolvePeriodBounds($employee, $year);
|
||||
$summary->presenceDaysByMonth = $this->computePresenceDaysByMonth($employee, $periodFrom, $periodTo);
|
||||
[$periodFrom, $periodTo] = $this->resolvePeriodBounds($employee, $year);
|
||||
// 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,
|
||||
$periodTo,
|
||||
$n1AbsencesBudget
|
||||
);
|
||||
|
||||
// Same logic as presenceDaysByMonth but bounded at today: number of presence days
|
||||
// accumulated from leave year start up to today (inclusive).
|
||||
$today = new DateTimeImmutable('today');
|
||||
$cappedTo = $today < $periodTo ? $today : $periodTo;
|
||||
$summary->presenceDaysToToday = $today < $periodFrom
|
||||
? 0.0
|
||||
: array_sum($this->computePresenceDaysByMonth(
|
||||
$employee,
|
||||
$periodFrom,
|
||||
$cappedTo,
|
||||
$n1AbsencesBudget
|
||||
));
|
||||
|
||||
return $summary;
|
||||
}
|
||||
@@ -686,8 +707,12 @@ final readonly class EmployeeLeaveSummaryProvider implements ProviderInterface
|
||||
*
|
||||
* @return array<string, float> YYYY-MM => presence day count
|
||||
*/
|
||||
private function computePresenceDaysByMonth(Employee $employee, DateTimeImmutable $from, DateTimeImmutable $to): array
|
||||
{
|
||||
private function computePresenceDaysByMonth(
|
||||
Employee $employee,
|
||||
DateTimeImmutable $from,
|
||||
DateTimeImmutable $to,
|
||||
float $n1AbsencesBudget = 0.0
|
||||
): array {
|
||||
$publicHolidays = $this->buildPublicHolidayMap($from, $to);
|
||||
$weekendWorkedDays = $this->workHourRepository->countWeekendWorkedDaysByMonth($employee, $from, $to);
|
||||
$absences = $this->absenceRepository->findByEmployeeAndOverlappingDateRange($employee, $from, $to);
|
||||
@@ -697,10 +722,20 @@ final readonly class EmployeeLeaveSummaryProvider implements ProviderInterface
|
||||
? $this->workHourRepository->findWorkedDatesAmong($employee, array_keys($publicHolidays))
|
||||
: [];
|
||||
|
||||
// Sort absences chronologically so N-1 budget (forfait only) is consumed in date order:
|
||||
// earliest absences attribute to N-1 first, later ones overflow to N and reduce presence.
|
||||
$sortedAbsences = $absences;
|
||||
usort(
|
||||
$sortedAbsences,
|
||||
static fn ($a, $b): int => $a->getStartDate() <=> $b->getStartDate()
|
||||
);
|
||||
|
||||
$remainingN1Budget = $n1AbsencesBudget;
|
||||
|
||||
// Count absence days per month, iterating day by day to handle multi-day absences
|
||||
// and properly distribute across months.
|
||||
$absenceDaysByMonth = [];
|
||||
foreach ($absences as $absence) {
|
||||
foreach ($sortedAbsences as $absence) {
|
||||
$start = DateTimeImmutable::createFromInterface($absence->getStartDate())->setTime(0, 0);
|
||||
$end = DateTimeImmutable::createFromInterface($absence->getEndDate())->setTime(0, 0);
|
||||
|
||||
@@ -718,6 +753,17 @@ final readonly class EmployeeLeaveSummaryProvider implements ProviderInterface
|
||||
continue;
|
||||
}
|
||||
|
||||
// Forfait: leaves taken from N-1 stock do NOT decrement presence days.
|
||||
// We chronologically consume the N-1 budget before counting any absence.
|
||||
if ($remainingN1Budget > 0.0) {
|
||||
$consumed = min($remainingN1Budget, $dayAmount);
|
||||
$remainingN1Budget -= $consumed;
|
||||
$dayAmount -= $consumed;
|
||||
if ($dayAmount <= 0.0) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$absenceDaysByMonth[$monthKey] = ($absenceDaysByMonth[$monthKey] ?? 0.0) + $dayAmount;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user