feat(rtt) : custom contract deficit counts as signed recovery (1h=1h, no bands)
This commit is contained in:
@@ -113,6 +113,54 @@ final class RttRecoveryComputationServiceTest extends TestCase
|
||||
self::assertSame(3 * 60, $base50);
|
||||
}
|
||||
|
||||
public function testBuildWeekDetailCustomDeficitKeepsSignedTotalAndFlatFlag(): void
|
||||
{
|
||||
$service = new ReflectionClass(RttRecoveryComputationService::class)->newInstanceWithoutConstructor();
|
||||
|
||||
// CUSTOM, semaine sous les heures : overtime -120 (worked 2h sur réf 4h).
|
||||
$detail = $this->invokePrivate(
|
||||
$service,
|
||||
'buildWeekRecoveryDetail',
|
||||
false, // isPresence
|
||||
false, // disableBonuses
|
||||
true, // isCustom
|
||||
-120, // overtimeTotalMinutes
|
||||
0, // rawBase25
|
||||
0, // rawBase50
|
||||
[], // dailyMinutes
|
||||
);
|
||||
|
||||
self::assertSame(-120, $detail->totalMinutes);
|
||||
self::assertTrue($detail->isFlatRecovery);
|
||||
self::assertSame(0, $detail->base25Minutes);
|
||||
self::assertSame(0, $detail->base50Minutes);
|
||||
}
|
||||
|
||||
public function testBuildWeekDetailCustomPositiveIsFlatOneToOne(): void
|
||||
{
|
||||
$service = new ReflectionClass(RttRecoveryComputationService::class)->newInstanceWithoutConstructor();
|
||||
|
||||
$detail = $this->invokePrivate($service, 'buildWeekRecoveryDetail', false, false, true, 180, 0, 0, []);
|
||||
|
||||
self::assertSame(180, $detail->totalMinutes); // 1h = 1h
|
||||
self::assertTrue($detail->isFlatRecovery);
|
||||
}
|
||||
|
||||
public function testBuildWeekDetailStandardKeepsBucketsAndBonuses(): void
|
||||
{
|
||||
$service = new ReflectionClass(RttRecoveryComputationService::class)->newInstanceWithoutConstructor();
|
||||
|
||||
// 39h : overtime 300, base25 240, base50 60.
|
||||
$detail = $this->invokePrivate($service, 'buildWeekRecoveryDetail', false, false, false, 300, 240, 60, []);
|
||||
|
||||
self::assertFalse($detail->isFlatRecovery);
|
||||
self::assertSame(240, $detail->base25Minutes);
|
||||
self::assertSame(60, $detail->bonus25Minutes); // round(240 * 0.25)
|
||||
self::assertSame(60, $detail->base50Minutes);
|
||||
self::assertSame(30, $detail->bonus50Minutes); // round(60 * 0.5)
|
||||
self::assertSame(300 + 60 + 30, $detail->totalMinutes);
|
||||
}
|
||||
|
||||
private function invokePrivate(object $obj, string $method, mixed ...$args): mixed
|
||||
{
|
||||
return new ReflectionClass($obj::class)->getMethod($method)->invoke($obj, ...$args);
|
||||
|
||||
Reference in New Issue
Block a user