fix : affichage des absences dans les heures vue semaine + refacto
This commit is contained in:
@@ -70,7 +70,8 @@ final class WorkHourWeeklySummaryProviderTest extends TestCase
|
||||
$user = new User();
|
||||
$timeEmployee = $this->buildEmployee(1, 'TIME', 35, 'Alice');
|
||||
$presenceEmployee = $this->buildEmployee(2, 'PRESENCE', null, 'Bob');
|
||||
$employees = [$timeEmployee, $presenceEmployee];
|
||||
$interimEmployee = $this->buildEmployee(3, 'TIME', 35, 'Charly', 'Interim');
|
||||
$employees = [$timeEmployee, $presenceEmployee, $interimEmployee];
|
||||
|
||||
$workHours = [];
|
||||
foreach (['2026-02-16', '2026-02-17', '2026-02-18', '2026-02-19', '2026-02-20'] as $date) {
|
||||
@@ -80,6 +81,12 @@ final class WorkHourWeeklySummaryProviderTest extends TestCase
|
||||
->setMorningFrom('09:00')
|
||||
->setMorningTo('19:00')
|
||||
;
|
||||
$workHours[] = new WorkHour()
|
||||
->setEmployee($interimEmployee)
|
||||
->setWorkDate(new DateTimeImmutable($date))
|
||||
->setMorningFrom('09:00')
|
||||
->setMorningTo('19:00')
|
||||
;
|
||||
}
|
||||
|
||||
$absenceType = new AbsenceType()
|
||||
@@ -117,22 +124,29 @@ final class WorkHourWeeklySummaryProviderTest extends TestCase
|
||||
|
||||
self::assertSame('2026-02-16', $result->weekStart);
|
||||
self::assertSame('2026-02-22', $result->weekEnd);
|
||||
self::assertCount(2, $result->rows);
|
||||
self::assertCount(3, $result->rows);
|
||||
|
||||
self::assertSame(3000, $result->rows[0]['weeklyTotalMinutes']);
|
||||
self::assertSame(900, $result->rows[0]['weeklyOvertimeTotalMinutes']);
|
||||
self::assertSame(120, $result->rows[0]['weeklyOvertime25Minutes']);
|
||||
self::assertSame(210, $result->rows[0]['weeklyOvertime50Minutes']);
|
||||
self::assertSame(1230, $result->rows[0]['weeklyRecoveryMinutes']);
|
||||
self::assertSame(3000, $result->rows[0]->weeklyTotalMinutes);
|
||||
self::assertSame(900, $result->rows[0]->weeklyOvertimeTotalMinutes);
|
||||
self::assertSame(120, $result->rows[0]->weeklyOvertime25Minutes);
|
||||
self::assertSame(210, $result->rows[0]->weeklyOvertime50Minutes);
|
||||
self::assertSame(1230, $result->rows[0]->weeklyRecoveryMinutes);
|
||||
|
||||
self::assertSame(1.0, $result->rows[1]['weeklyPresenceCount']);
|
||||
self::assertSame(0, $result->rows[1]['weeklyOvertimeTotalMinutes']);
|
||||
self::assertSame(1.0, $result->rows[1]->weeklyPresenceCount);
|
||||
self::assertTrue($result->rows[1]->daily[0]->hasAbsence);
|
||||
self::assertSame('Congé', $result->rows[1]->daily[0]->absenceLabel);
|
||||
self::assertSame('#000', $result->rows[1]->daily[0]->absenceColor);
|
||||
self::assertSame(0, $result->rows[1]->weeklyOvertimeTotalMinutes);
|
||||
self::assertSame(0, $result->rows[2]->weeklyOvertime25Minutes);
|
||||
self::assertSame(0, $result->rows[2]->weeklyOvertime50Minutes);
|
||||
self::assertSame(0, $result->rows[2]->weeklyRecoveryMinutes);
|
||||
self::assertSame(900, $result->rows[2]->weeklyOvertimeTotalMinutes);
|
||||
}
|
||||
|
||||
private function buildEmployee(int $id, string $trackingMode, ?int $weeklyHours, string $firstName): Employee
|
||||
private function buildEmployee(int $id, string $trackingMode, ?int $weeklyHours, string $firstName, ?string $contractName = null): Employee
|
||||
{
|
||||
$contract = new Contract()
|
||||
->setName($trackingMode)
|
||||
->setName($contractName ?? $trackingMode)
|
||||
->setTrackingMode($trackingMode)
|
||||
->setWeeklyHours($weeklyHours)
|
||||
;
|
||||
|
||||
Reference in New Issue
Block a user