feat : ajout des suspensions et des jours de présence
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:
@@ -263,6 +263,36 @@ class Employee
|
||||
return $this->resolveCurrentContractPeriod()?->getEndDate()?->format('Y-m-d');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<array{id: null|int, startDate: string, endDate: null|string, comment: null|string}>
|
||||
*/
|
||||
#[Groups(['employee:read'])]
|
||||
public function getCurrentSuspensions(): array
|
||||
{
|
||||
$currentPeriod = $this->resolveCurrentContractPeriod();
|
||||
if (null === $currentPeriod) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return array_values(array_map(
|
||||
static fn (ContractSuspension $s): array => [
|
||||
'id' => $s->getId(),
|
||||
'startDate' => $s->getStartDate()->format('Y-m-d'),
|
||||
'endDate' => $s->getEndDate()?->format('Y-m-d'),
|
||||
'comment' => $s->getComment(),
|
||||
],
|
||||
$currentPeriod->getSuspensions()->toArray()
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, EmployeeContractPeriod>
|
||||
*/
|
||||
public function getContractPeriods(): Collection
|
||||
{
|
||||
return $this->contractPeriods;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<ContractHistoryItem>
|
||||
*/
|
||||
@@ -279,6 +309,16 @@ class Employee
|
||||
static function (EmployeeContractPeriod $period): ContractHistoryItem {
|
||||
$contract = $period->getContract();
|
||||
|
||||
$suspensionData = array_map(
|
||||
static fn (ContractSuspension $s): array => [
|
||||
'id' => $s->getId(),
|
||||
'startDate' => $s->getStartDate()->format('Y-m-d'),
|
||||
'endDate' => $s->getEndDate()?->format('Y-m-d'),
|
||||
'comment' => $s->getComment(),
|
||||
],
|
||||
$period->getSuspensions()->toArray()
|
||||
);
|
||||
|
||||
return new ContractHistoryItem(
|
||||
contractId: $contract?->getId(),
|
||||
contractName: $contract?->getName(),
|
||||
@@ -287,6 +327,8 @@ class Employee
|
||||
startDate: $period->getStartDate()->format('Y-m-d'),
|
||||
endDate: $period->getEndDate()?->format('Y-m-d'),
|
||||
comment: $period->getComment(),
|
||||
periodId: $period->getId(),
|
||||
suspensions: $suspensionData,
|
||||
);
|
||||
},
|
||||
$periods
|
||||
|
||||
Reference in New Issue
Block a user