feat : modification de la gestion des jours fériés
All checks were successful
Auto Tag Develop / tag (push) Successful in 6s
All checks were successful
Auto Tag Develop / tag (push) Successful in 6s
This commit is contained in:
@@ -23,6 +23,8 @@ use App\Repository\Contract\EmployeeScopedRepositoryInterface;
|
||||
use App\Repository\Contract\WorkHourReadRepositoryInterface;
|
||||
use App\Service\Contracts\EmployeeContractResolver;
|
||||
use App\Service\WorkHours\AbsenceSegmentsResolver;
|
||||
use App\Service\WorkHours\DailyReferenceMinutesResolver;
|
||||
use App\Service\WorkHours\HolidayVirtualHoursResolver;
|
||||
use App\Service\WorkHours\WorkedHoursCreditPolicy;
|
||||
use DateTimeImmutable;
|
||||
use Symfony\Bundle\SecurityBundle\Security;
|
||||
@@ -41,6 +43,8 @@ final readonly class WorkHourWeeklySummaryProvider implements ProviderInterface
|
||||
private AbsenceSegmentsResolver $absenceSegmentsResolver,
|
||||
private WorkedHoursCreditPolicy $workedHoursCreditPolicy,
|
||||
private EmployeeContractResolver $contractResolver,
|
||||
private DailyReferenceMinutesResolver $dailyReferenceResolver,
|
||||
private HolidayVirtualHoursResolver $holidayVirtualHoursResolver,
|
||||
) {}
|
||||
|
||||
public function provide(Operation $operation, array $uriVariables = [], array $context = []): WorkHourWeeklySummary
|
||||
@@ -117,6 +121,7 @@ final readonly class WorkHourWeeklySummaryProvider implements ProviderInterface
|
||||
$contractsByEmployeeDate = $this->contractResolver->resolveForEmployeesAndDays($employees, $days);
|
||||
$contractNaturesByEmployeeDate = $this->contractResolver->resolveNaturesForEmployeesAndDays($employees, $days);
|
||||
$isDriverByEmployeeDate = $this->contractResolver->resolveIsDriverForEmployeesAndDays($employees, $days);
|
||||
$workDaysByEmployeeDate = $this->contractResolver->resolveWorkDaysMinutesForEmployeesAndDays($employees, $days);
|
||||
$metricsByEmployeeDate = [];
|
||||
foreach ($workHours as $workHour) {
|
||||
$employeeId = $workHour->getEmployee()?->getId();
|
||||
@@ -276,6 +281,25 @@ final readonly class WorkHourWeeklySummaryProvider implements ProviderInterface
|
||||
++$weeklyNightBasketCount;
|
||||
}
|
||||
|
||||
// Apply the Mon-Fri public holiday credit rule: for non-Forfait contracts,
|
||||
// if the total worked is below the contract-expected daily hours, top it up.
|
||||
// Virtual minutes are always accounted against the "day" bucket.
|
||||
// When an absence is declared on the day, the holiday credit is bypassed —
|
||||
// the absence (via WorkedHoursCreditPolicy) dictates the hours.
|
||||
$virtualHolidayMinutes = $this->holidayVirtualHoursResolver
|
||||
->resolveVirtualCredit(
|
||||
$contractAtDate,
|
||||
new DateTimeImmutable($date),
|
||||
$absenceByEmployeeDate[$employeeId][$date] ?? false,
|
||||
$workDaysByEmployeeDate[$employeeId][$date] ?? null,
|
||||
)
|
||||
;
|
||||
if ($virtualHolidayMinutes > $totalMinutes) {
|
||||
$delta = $virtualHolidayMinutes - $totalMinutes;
|
||||
$dayMinutes += $delta;
|
||||
$totalMinutes = $virtualHolidayMinutes;
|
||||
}
|
||||
|
||||
$weeklyDayMinutes += $dayMinutes;
|
||||
$weeklyNightMinutes += $nightMinutes;
|
||||
$weeklyWorkshopMinutes += $workshopMinutes;
|
||||
@@ -299,6 +323,7 @@ final readonly class WorkHourWeeklySummaryProvider implements ProviderInterface
|
||||
hasLunch: $hasLunch,
|
||||
hasDinner: $hasDinner,
|
||||
hasOvernight: $hasOvernight,
|
||||
virtualHolidayMinutes: $virtualHolidayMinutes,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -512,23 +537,6 @@ final readonly class WorkHourWeeklySummaryProvider implements ProviderInterface
|
||||
|
||||
private function resolveDailyReferenceMinutes(?int $weeklyHours, int $isoWeekDay): int
|
||||
{
|
||||
// Week-end hors base de référence.
|
||||
if ($isoWeekDay >= 6) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (null === $weeklyHours || $weeklyHours <= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (39 === $weeklyHours) {
|
||||
return 5 === $isoWeekDay ? 7 * 60 : 8 * 60;
|
||||
}
|
||||
|
||||
if (35 === $weeklyHours) {
|
||||
return 7 * 60;
|
||||
}
|
||||
|
||||
return (int) round(($weeklyHours * 60) / 5);
|
||||
return $this->dailyReferenceResolver->resolve($weeklyHours, $isoWeekDay);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user