Gestion du changement de type de contrat + correction du calcule des RTT sur un contrat qui commence en milieu de semaine (#19)
Auto Tag Develop / tag (push) Has been cancelled

| Numéro du ticket | Titre du ticket |
|------------------|-----------------|
|                  |                 |

## Description de la PR

## Modification du .env

## Check list

- [x] Pas de régression
- [x] TU/TI/TF rédigée
- [x] TU/TI/TF OK
- [x] CHANGELOG modifié

Reviewed-on: #19
Co-authored-by: tristan <tristan@yuno.malio.fr>
Co-committed-by: tristan <tristan@yuno.malio.fr>
This commit was merged in pull request #19.
This commit is contained in:
2026-05-22 06:42:33 +00:00
committed by Autin
parent b541f9ded8
commit abdaf809f8
40 changed files with 5021 additions and 153 deletions
+39
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,43 @@ class Employee
);
}
/**
* @return list<array{
* id: int,
* contractType: string,
* weeklyHours: ?int,
* isDriver: bool,
* startDate: string,
* endDate: ?string,
* periodIds: list<int>,
* isCurrent: bool,
* contractNature: string
* }>
*/
#[Groups(['employee:read'])]
public function getContractPhases(): array
{
// Read RTT_START_DATE directly here: the entity has no DI but must filter
// out contract phases that ended before the application's data start.
$rawDate = $_SERVER['RTT_START_DATE'] ?? $_ENV['RTT_START_DATE'] ?? '';
$resolver = new EmployeeContractPhaseResolver(is_string($rawDate) ? $rawDate : '');
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,
'contractNature' => $phase->contractNature->value,
],
$resolver->resolvePhases($this),
);
}
private function resolveCurrentContractPeriod(): ?EmployeeContractPeriod
{
$today = new DateTimeImmutable('today');