Gestion du changement de type de contrat + correction du calcule des RTT sur un contrat qui commence en milieu de semaine #19

Merged
tristan merged 55 commits from feat/contract-phase-view-selector into develop 2026-05-22 06:42:33 +00:00
Showing only changes of commit e7035a7c30 - Show all commits

View File

@@ -6,9 +6,11 @@ namespace App\Entity;
use ApiPlatform\Metadata\ApiProperty;
use ApiPlatform\Metadata\ApiResource;
use App\Dto\Contracts\ContractPhase;
use App\Dto\Employees\ContractHistoryItem;
use App\Enum\ContractNature;
use App\Repository\EmployeeRepository;
use App\Service\Contracts\EmployeeContractPhaseResolver;
use App\State\EmployeeWriteProcessor;
use DateTimeImmutable;
use Doctrine\Common\Collections\ArrayCollection;
@@ -428,6 +430,38 @@ class Employee
);
}
/**
* @return list<array{
* id: int,
* contractType: string,
* weeklyHours: ?int,
* isDriver: bool,
* startDate: string,
* endDate: ?string,
* periodIds: list<int>,
* isCurrent: bool
* }>
*/
#[Groups(['employee:read'])]
public function getContractPhases(): array
{
$resolver = new EmployeeContractPhaseResolver();
return array_map(
static fn (ContractPhase $phase): array => [
'id' => $phase->id,
'contractType' => $phase->contractType->value,
'weeklyHours' => $phase->weeklyHours,
'isDriver' => $phase->isDriver,
'startDate' => $phase->startDate->format('Y-m-d'),
'endDate' => $phase->endDate?->format('Y-m-d'),
'periodIds' => $phase->periodIds,
'isCurrent' => $phase->isCurrent,
],
$resolver->resolvePhases($this),
);
}
private function resolveCurrentContractPeriod(): ?EmployeeContractPeriod
{
$today = new DateTimeImmutable('today');