[#SIRH-36] corriger calcule rtt contrat custom (#27)
Auto Tag Develop / tag (push) Successful in 7s

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

## Description de la PR

## Modification du .env

## Check list

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

Reviewed-on: #27
Co-authored-by: tristan <tristan@yuno.malio.fr>
Co-committed-by: tristan <tristan@yuno.malio.fr>
This commit was merged in pull request #27.
This commit is contained in:
2026-06-11 08:36:57 +00:00
committed by Autin
parent 081d92b9f4
commit f0387233e4
20 changed files with 1997 additions and 57 deletions
+56 -1
View File
@@ -5,6 +5,7 @@ declare(strict_types=1);
namespace App\Tests\State;
use App\Dto\Contracts\ContractPhase;
use App\Dto\Rtt\EmployeeRttWeekSummary;
use App\Entity\Contract;
use App\Entity\Employee;
use App\Entity\EmployeeContractPeriod;
@@ -201,6 +202,45 @@ final class EmployeeRttSummaryProviderTest extends TestCase
self::assertSame(2030, $year);
}
public function testFlatDeficitWeekIsNotDrainedFromTiers(): void
{
$provider = $this->buildProvider([]);
// Semaine CUSTOM déficitaire (-120), aucune tranche accumulée.
$weeks = [$this->weekSummary(-120, true)];
$result = $this->invokePrivate($provider, 'applyDeficitCascade', $weeks, 0, 0);
// Buckets restent à 0 ; le total négatif est conservé (le cumul est calculé ailleurs).
self::assertSame(0, $result[0]->base25Minutes);
self::assertSame(0, $result[0]->base50Minutes);
self::assertSame(-120, $result[0]->totalMinutes);
self::assertTrue($result[0]->isFlatRecovery);
}
public function testStandardDeficitWeekDrainsFiftyThenTwentyFive(): void
{
$provider = $this->buildProvider([]);
// Semaine 35h/39h déficitaire (-100), avec 60 en 50% et 120 en 25% accumulés.
$weeks = [$this->weekSummary(-100, false)];
$result = $this->invokePrivate($provider, 'applyDeficitCascade', $weeks, 120, 60);
self::assertSame(-60, $result[0]->base50Minutes); // 60 drainés du 50%
self::assertSame(-40, $result[0]->base25Minutes); // 40 restants drainés du 25%
self::assertSame(-100, $result[0]->totalMinutes);
}
public function testFlatPositiveWeekIsUntouched(): void
{
$provider = $this->buildProvider([]);
$weeks = [$this->weekSummary(180, true)];
$result = $this->invokePrivate($provider, 'applyDeficitCascade', $weeks, 0, 0);
self::assertSame(180, $result[0]->totalMinutes);
self::assertSame(0, $result[0]->base25Minutes);
}
// -----------------------------------------------------------------------
// Test harness helpers.
// -----------------------------------------------------------------------
@@ -247,6 +287,21 @@ final class EmployeeRttSummaryProviderTest extends TestCase
return $employee;
}
private function weekSummary(int $totalMinutes, bool $isFlat, int $base25 = 0, int $base50 = 0): EmployeeRttWeekSummary
{
return new EmployeeRttWeekSummary(
month: 6,
weekNumber: 1,
weekStart: '2026-06-01',
weekEnd: '2026-06-07',
overtimeMinutes: $totalMinutes,
base25Minutes: $base25,
base50Minutes: $base50,
totalMinutes: $totalMinutes,
isFlatRecovery: $isFlat,
);
}
/**
* Build an uninitialized provider with a RequestStack pre-loaded with the given query.
*
@@ -256,7 +311,7 @@ final class EmployeeRttSummaryProviderTest extends TestCase
* only setting the properties that the tested private methods actually read:
* `requestStack` and `phaseResolver`.
*
* @param array<string, string> $request query parameters (year, phaseId, ...)
* @param array<string, string> $request
*/
private function buildProvider(array $request = []): EmployeeRttSummaryProvider
{