Retour RH: vue jour par date, RTT mi-semaine, récap salaire & exports, panier de nuit #21
@@ -21,6 +21,10 @@ final class DayContextRow
|
|||||||
public ?string $formationLabel = null,
|
public ?string $formationLabel = null,
|
||||||
public int $virtualHolidayMinutes = 0,
|
public int $virtualHolidayMinutes = 0,
|
||||||
public ?string $contractNature = null,
|
public ?string $contractNature = null,
|
||||||
|
public ?string $trackingMode = null,
|
||||||
|
public ?int $weeklyHours = null,
|
||||||
|
public ?string $contractType = null,
|
||||||
|
public ?string $contractName = null,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
public function setFormation(string $label): void
|
public function setFormation(string $label): void
|
||||||
@@ -79,7 +83,11 @@ final class DayContextRow
|
|||||||
* hasFormation:bool,
|
* hasFormation:bool,
|
||||||
* formationLabel:?string,
|
* formationLabel:?string,
|
||||||
* virtualHolidayMinutes:int,
|
* virtualHolidayMinutes:int,
|
||||||
* contractNature:?string
|
* contractNature:?string,
|
||||||
|
* trackingMode:?string,
|
||||||
|
* weeklyHours:?int,
|
||||||
|
* contractType:?string,
|
||||||
|
* contractName:?string
|
||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
public function toArray(): array
|
public function toArray(): array
|
||||||
@@ -99,6 +107,10 @@ final class DayContextRow
|
|||||||
'formationLabel' => $this->formationLabel,
|
'formationLabel' => $this->formationLabel,
|
||||||
'virtualHolidayMinutes' => $this->virtualHolidayMinutes,
|
'virtualHolidayMinutes' => $this->virtualHolidayMinutes,
|
||||||
'contractNature' => $this->contractNature,
|
'contractNature' => $this->contractNature,
|
||||||
|
'trackingMode' => $this->trackingMode,
|
||||||
|
'weeklyHours' => $this->weeklyHours,
|
||||||
|
'contractType' => $this->contractType,
|
||||||
|
'contractName' => $this->contractName,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -68,6 +68,10 @@ final readonly class WorkHourDayContextProvider implements ProviderInterface
|
|||||||
isDriverContract: $this->contractResolver->resolveIsDriverForEmployeeAndDate($employee, $workDate),
|
isDriverContract: $this->contractResolver->resolveIsDriverForEmployeeAndDate($employee, $workDate),
|
||||||
virtualHolidayMinutes: $this->holidayVirtualHoursResolver->resolveVirtualCredit($contract, $workDate, false, $workDaysMinutes),
|
virtualHolidayMinutes: $this->holidayVirtualHoursResolver->resolveVirtualCredit($contract, $workDate, false, $workDaysMinutes),
|
||||||
contractNature: $contractNature,
|
contractNature: $contractNature,
|
||||||
|
trackingMode: $contract?->getTrackingMode(),
|
||||||
|
weeklyHours: $contract?->getWeeklyHours(),
|
||||||
|
contractType: $contract?->getType()->value,
|
||||||
|
contractName: $contract?->getName(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -126,6 +126,60 @@ final class WorkHourDayContextProviderTest extends TestCase
|
|||||||
self::assertSame(210, $result->rows[0]['creditedMinutes']);
|
self::assertSame(210, $result->rows[0]['creditedMinutes']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testRowCarriesContractAtRequestedDate(): void
|
||||||
|
{
|
||||||
|
$user = new User();
|
||||||
|
|
||||||
|
$timeContract = new Contract()
|
||||||
|
->setName('Contrat')
|
||||||
|
->setTrackingMode(Contract::TRACKING_TIME)
|
||||||
|
->setWeeklyHours(39)
|
||||||
|
;
|
||||||
|
$forfaitContract = new Contract()
|
||||||
|
->setName('Forfait')
|
||||||
|
->setTrackingMode(Contract::TRACKING_PRESENCE)
|
||||||
|
->setWeeklyHours(null)
|
||||||
|
;
|
||||||
|
$employee = new Employee()
|
||||||
|
->setFirstName('Jean')
|
||||||
|
->setLastName('Test')
|
||||||
|
->setContract($forfaitContract)
|
||||||
|
;
|
||||||
|
$this->setEntityId($employee, 1);
|
||||||
|
|
||||||
|
// Resolver renvoie le contrat 39h avant 2026-03-01, le forfait à partir de cette date.
|
||||||
|
$resolver = $this->createStub(EmployeeContractResolver::class);
|
||||||
|
$resolver->method('resolveForEmployeeAndDate')->willReturnCallback(
|
||||||
|
static fn (Employee $e, \DateTimeImmutable $d): ?Contract =>
|
||||||
|
$d < new \DateTimeImmutable('2026-03-01') ? $timeContract : $forfaitContract
|
||||||
|
);
|
||||||
|
$resolver->method('resolveNatureForEmployeeAndDate')->willReturn(ContractNature::CDI);
|
||||||
|
|
||||||
|
$this->requestStack->push(new Request(query: ['workDate' => '2026-02-16']));
|
||||||
|
$this->security->method('getUser')->willReturn($user);
|
||||||
|
$this->employeeRepository->method('findScoped')->with($user)->willReturn([$employee]);
|
||||||
|
$this->absenceRepository->method('findByDateAndEmployees')->willReturn([]);
|
||||||
|
|
||||||
|
$provider = new WorkHourDayContextProvider(
|
||||||
|
$this->security,
|
||||||
|
$this->requestStack,
|
||||||
|
$this->employeeRepository,
|
||||||
|
$this->absenceRepository,
|
||||||
|
$this->formationRepository,
|
||||||
|
$resolver,
|
||||||
|
new AbsenceSegmentsResolver(),
|
||||||
|
new WorkedHoursCreditPolicy($this->buildResolverStub(), new DailyReferenceMinutesResolver()),
|
||||||
|
$this->buildHolidayResolver(),
|
||||||
|
);
|
||||||
|
|
||||||
|
$row = $provider->provide(new Get())->rows[0];
|
||||||
|
|
||||||
|
self::assertSame('TIME', $row['trackingMode']);
|
||||||
|
self::assertSame(39, $row['weeklyHours']);
|
||||||
|
self::assertSame('39H', $row['contractType']);
|
||||||
|
self::assertSame('Contrat', $row['contractName']);
|
||||||
|
}
|
||||||
|
|
||||||
private function buildEmployee(int $id, string $trackingMode, ?int $weeklyHours): Employee
|
private function buildEmployee(int $id, string $trackingMode, ?int $weeklyHours): Employee
|
||||||
{
|
{
|
||||||
$contract = new Contract()
|
$contract = new Contract()
|
||||||
|
|||||||
Reference in New Issue
Block a user