feat : modification des exports PDF et affichage du type de contrat sur l'écran des heures
Some checks failed
Auto Tag Develop / tag (push) Has been cancelled
Some checks failed
Auto Tag Develop / tag (push) Has been cancelled
This commit is contained in:
@@ -18,12 +18,14 @@ use App\Repository\MileageAllowanceRepository;
|
||||
use App\Repository\ObservationRepository;
|
||||
use App\Repository\WorkHourRepository;
|
||||
use App\Service\Contracts\EmployeeContractResolver;
|
||||
use App\Service\PublicHolidayServiceInterface;
|
||||
use DateInterval;
|
||||
use DateTimeImmutable;
|
||||
use Dompdf\Dompdf;
|
||||
use Dompdf\Options;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Throwable;
|
||||
use Twig\Environment;
|
||||
|
||||
class SalaryRecapPrintProvider implements ProviderInterface
|
||||
@@ -39,6 +41,7 @@ class SalaryRecapPrintProvider implements ProviderInterface
|
||||
private MileageAllowanceRepository $mileageAllowanceRepository,
|
||||
private ObservationRepository $observationRepository,
|
||||
private EmployeeContractResolver $contractResolver,
|
||||
private PublicHolidayServiceInterface $publicHolidayService,
|
||||
) {}
|
||||
|
||||
public function provide(Operation $operation, array $uriVariables = [], array $context = []): Response
|
||||
@@ -71,6 +74,7 @@ class SalaryRecapPrintProvider implements ProviderInterface
|
||||
$days = $this->buildDays($from, $to);
|
||||
$contractMap = $this->contractResolver->resolveForEmployeesAndDays($employees, $days);
|
||||
$driverMap = $this->contractResolver->resolveIsDriverForEmployeesAndDays($employees, $days);
|
||||
$holidayMap = $this->buildHolidayMap($from, $to);
|
||||
|
||||
$workHourMap = $this->buildWorkHourMap($workHours);
|
||||
$absenceMap = $this->buildAbsenceMap($absences);
|
||||
@@ -79,7 +83,7 @@ class SalaryRecapPrintProvider implements ProviderInterface
|
||||
$mileageMap = $this->buildMileageMap($mileages);
|
||||
$observationMap = $this->buildObservationMap($observations);
|
||||
|
||||
$siteGroups = $this->aggregateBySite($employees, $days, $contractMap, $driverMap, $workHourMap, $absenceMap, $rttPaymentMap, $bonusMap, $mileageMap, $observationMap);
|
||||
$siteGroups = $this->aggregateBySite($employees, $days, $contractMap, $driverMap, $workHourMap, $absenceMap, $rttPaymentMap, $bonusMap, $mileageMap, $observationMap, $holidayMap);
|
||||
|
||||
$options = new Options();
|
||||
$options->set('isRemoteEnabled', true);
|
||||
@@ -208,6 +212,29 @@ class SalaryRecapPrintProvider implements ProviderInterface
|
||||
return $map;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, string> Y-m-d → label
|
||||
*/
|
||||
private function buildHolidayMap(DateTimeImmutable $from, DateTimeImmutable $to): array
|
||||
{
|
||||
$map = [];
|
||||
$startYear = (int) $from->format('Y');
|
||||
$endYear = (int) $to->format('Y');
|
||||
|
||||
try {
|
||||
for ($year = $startYear; $year <= $endYear; ++$year) {
|
||||
$holidays = $this->publicHolidayService->getHolidaysDayByYears('metropole', (string) $year);
|
||||
foreach ($holidays as $date => $label) {
|
||||
$map[(string) $date] = (string) $label;
|
||||
}
|
||||
}
|
||||
} catch (Throwable) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return $map;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int, string>
|
||||
*/
|
||||
@@ -236,6 +263,7 @@ class SalaryRecapPrintProvider implements ProviderInterface
|
||||
array $bonusMap,
|
||||
array $mileageMap,
|
||||
array $observationMap,
|
||||
array $holidayMap,
|
||||
): array {
|
||||
$siteGroups = [];
|
||||
|
||||
@@ -257,6 +285,7 @@ class SalaryRecapPrintProvider implements ProviderInterface
|
||||
$bonusMap[$employeeId] ?? 0.0,
|
||||
$mileageMap[$employeeId] ?? 0.0,
|
||||
$observationMap[$employeeId] ?? '',
|
||||
$holidayMap,
|
||||
);
|
||||
|
||||
if (!isset($siteGroups[$siteId])) {
|
||||
@@ -285,18 +314,20 @@ class SalaryRecapPrintProvider implements ProviderInterface
|
||||
float $bonusAmount,
|
||||
float $mileageKm,
|
||||
string $observation,
|
||||
array $holidayMap,
|
||||
): array {
|
||||
$contractName = null;
|
||||
$presenceDays = 0.0;
|
||||
$nightMinutesTotal = 0;
|
||||
$nightBasketCount = 0;
|
||||
$sundayMinutesTotal = 0;
|
||||
$isDriverAnyDay = false;
|
||||
$driverBreakfast = 0;
|
||||
$driverMeals = 0;
|
||||
$driverOvernight = 0;
|
||||
$driverSaturdays = 0;
|
||||
$isForfait = false;
|
||||
$contractName = null;
|
||||
$presenceDays = 0.0;
|
||||
$nightMinutesTotal = 0;
|
||||
$nightBasketCount = 0;
|
||||
$sundayMinutesTotal = 0;
|
||||
$holidayMinutesTotal = 0;
|
||||
$isDriverAnyDay = false;
|
||||
$driverBreakfast = 0;
|
||||
$driverMeals = 0;
|
||||
$driverOvernight = 0;
|
||||
$driverSaturdays = 0;
|
||||
$isForfait = false;
|
||||
|
||||
foreach ($days as $date) {
|
||||
$contract = $contractsByDate[$date] ?? null;
|
||||
@@ -318,10 +349,13 @@ class SalaryRecapPrintProvider implements ProviderInterface
|
||||
|
||||
$dayOfWeek = (int) new DateTimeImmutable($date)->format('N');
|
||||
|
||||
$isHoliday = isset($holidayMap[$date]);
|
||||
|
||||
if ($isDriver) {
|
||||
$nightMinutesTotal += $wh->getNightHoursMinutes() ?? 0;
|
||||
$dayMin = $wh->getDayHoursMinutes() ?? 0;
|
||||
$nightMin = $wh->getNightHoursMinutes() ?? 0;
|
||||
$dayMin = $wh->getDayHoursMinutes() ?? 0;
|
||||
$nightMin = $wh->getNightHoursMinutes() ?? 0;
|
||||
$workshopMin = $wh->getWorkshopHoursMinutes() ?? 0;
|
||||
if (($nightMin > $dayMin && $nightMin > 0) || $nightMin >= 240) {
|
||||
++$nightBasketCount;
|
||||
}
|
||||
@@ -336,12 +370,16 @@ class SalaryRecapPrintProvider implements ProviderInterface
|
||||
++$driverOvernight;
|
||||
}
|
||||
|
||||
if (6 === $dayOfWeek && ($dayMin > 0 || $nightMin > 0 || ($wh->getWorkshopHoursMinutes() ?? 0) > 0)) {
|
||||
if (6 === $dayOfWeek && ($dayMin > 0 || $nightMin > 0 || $workshopMin > 0)) {
|
||||
++$driverSaturdays;
|
||||
}
|
||||
|
||||
if (7 === $dayOfWeek) {
|
||||
$sundayMinutesTotal += $dayMin + $nightMin + ($wh->getWorkshopHoursMinutes() ?? 0);
|
||||
$sundayMinutesTotal += $dayMin + $nightMin + $workshopMin;
|
||||
}
|
||||
|
||||
if ($isHoliday) {
|
||||
$holidayMinutesTotal += $dayMin + $nightMin + $workshopMin;
|
||||
}
|
||||
} else {
|
||||
$metrics = $this->computeNightMinutes($wh);
|
||||
@@ -359,6 +397,10 @@ class SalaryRecapPrintProvider implements ProviderInterface
|
||||
$sundayMinutesTotal += $this->computeOverflowAfterMidnight($wh);
|
||||
}
|
||||
|
||||
if ($isHoliday) {
|
||||
$holidayMinutesTotal += $metrics['dayMinutes'] + $metrics['nightMinutes'];
|
||||
}
|
||||
|
||||
if ($isForfait) {
|
||||
if ($wh->getIsPresentMorning()) {
|
||||
$presenceDays += 0.5;
|
||||
@@ -373,9 +415,10 @@ class SalaryRecapPrintProvider implements ProviderInterface
|
||||
$conges = $this->countAbsencesByCode($absences, ['C']);
|
||||
$maladie = $this->countAbsencesByCode($absences, ['M', 'AT']);
|
||||
|
||||
$nightHours = round($nightMinutesTotal / 60, 2);
|
||||
$paidHours = round($rttPaidMinutes / 60, 2);
|
||||
$sundayHours = round($sundayMinutesTotal / 60, 2);
|
||||
$nightHours = round($nightMinutesTotal / 60, 2);
|
||||
$paidHours = round($rttPaidMinutes / 60, 2);
|
||||
$sundayHours = round($sundayMinutesTotal / 60, 2);
|
||||
$holidayHours = round($holidayMinutesTotal / 60, 2);
|
||||
|
||||
return [
|
||||
'lastName' => mb_strimwidth($employee->getLastName() ?? '', 0, 15, '...'),
|
||||
@@ -387,6 +430,7 @@ class SalaryRecapPrintProvider implements ProviderInterface
|
||||
'nightBasketCount' => $nightBasketCount,
|
||||
'paidHours' => $paidHours,
|
||||
'sundayHours' => $sundayHours,
|
||||
'holidayHours' => $holidayHours,
|
||||
'bonusAmount' => $bonusAmount,
|
||||
'congesCount' => $conges['count'],
|
||||
'congesDates' => $conges['dates'],
|
||||
|
||||
Reference in New Issue
Block a user