fix : écran du récap. congés ordre d'affichage + Calcule des jours ouvrés pour les FORFAIT
This commit is contained in:
@@ -7,8 +7,10 @@ namespace App\State;
|
||||
use ApiPlatform\Metadata\Operation;
|
||||
use ApiPlatform\State\ProviderInterface;
|
||||
use App\ApiResource\EmployeeLeaveRecap;
|
||||
use App\Entity\Contract;
|
||||
use App\Entity\Employee;
|
||||
use App\Entity\User;
|
||||
use App\Enum\ContractType;
|
||||
use App\Repository\EmployeeRepository;
|
||||
use App\Security\EmployeeScopeService;
|
||||
use App\Service\Leave\LeaveRecapRowBuilder;
|
||||
@@ -63,6 +65,7 @@ final readonly class EmployeeLeaveRecapProvider implements ProviderInterface
|
||||
$resource->siteName = $site?->getName();
|
||||
$resource->siteColor = $site?->getColor();
|
||||
$resource->contractName = $row['contractName'] ?? null;
|
||||
$resource->contractSortKey = $this->resolveContractSortKey($employee->getContract());
|
||||
$resource->cpN1Remaining = is_numeric($row['cpN1Remaining']) ? (float) $row['cpN1Remaining'] : 0.0;
|
||||
$resource->cpN = (string) $row['cpN'];
|
||||
$resource->acquiredSaturdays = (string) $row['acquiredSaturdays'];
|
||||
@@ -78,6 +81,10 @@ final readonly class EmployeeLeaveRecapProvider implements ProviderInterface
|
||||
if (0 !== $siteCmp) {
|
||||
return $siteCmp;
|
||||
}
|
||||
$contractCmp = $a->contractSortKey <=> $b->contractSortKey;
|
||||
if (0 !== $contractCmp) {
|
||||
return $contractCmp;
|
||||
}
|
||||
$lastCmp = strcmp($a->lastName, $b->lastName);
|
||||
if (0 !== $lastCmp) {
|
||||
return $lastCmp;
|
||||
@@ -89,6 +96,30 @@ final readonly class EmployeeLeaveRecapProvider implements ProviderInterface
|
||||
return $rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort order: FORFAIT → 39h → 35h → 25h → 4h → autres.
|
||||
*/
|
||||
private function resolveContractSortKey(?Contract $contract): int
|
||||
{
|
||||
if (null === $contract) {
|
||||
return 99;
|
||||
}
|
||||
|
||||
if (ContractType::FORFAIT === $contract->getType()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$weeklyHours = $contract->getWeeklyHours();
|
||||
|
||||
return match ($weeklyHours) {
|
||||
39 => 1,
|
||||
35 => 2,
|
||||
25 => 3,
|
||||
4 => 4,
|
||||
default => 99,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<Employee>
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user