fix(conges) : un congé posé un dimanche n'est plus décompté (récap salaire)
Auto Tag Develop / tag (push) Successful in 11s
Auto Tag Develop / tag (push) Successful in 11s
Le récap salaire comptait les congés (C) tombant un dimanche via countAbsencesByCode, alors que l'onglet Congés, le rollover et les jours de présence l'ignoraient déjà. Garde ajoutée (C + dimanche → ignoré) pour aligner : poser une période à cheval sur un week-end (ex. jeu→mar) ne fait plus perdre le dimanche. Correctif au comptage uniquement : les lignes d'absence du dimanche restent créées et affichées sur le calendrier (volonté RH), l'existant cesse de compter sans migration. Périmètre strict : code C (maladie/AT inchangés), samedi inchangé (budget dédié). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace App\Tests\State;
|
||||
|
||||
use App\Entity\Absence;
|
||||
use App\Entity\AbsenceType;
|
||||
use App\Entity\Employee;
|
||||
use App\Entity\EmployeeContractPeriod;
|
||||
use App\Enum\HalfDay;
|
||||
@@ -96,13 +97,76 @@ final class SalaryRecapPrintProviderTest extends TestCase
|
||||
self::assertFalse($this->hasInRange(new Employee(), '2026-06-01', '2026-06-30'));
|
||||
}
|
||||
|
||||
public function testSundayCongeIsNotCounted(): void
|
||||
{
|
||||
// Congé (C) posé un dimanche (2026-06-07) : ne doit pas compter comme congé pris.
|
||||
$result = $this->countByCode([$this->buildAbsenceWithCode('2026-06-07', 'C')], ['C']);
|
||||
|
||||
self::assertSame(0.0, $result['count']);
|
||||
self::assertSame('', $result['dates']);
|
||||
}
|
||||
|
||||
public function testSaturdayCongeStillCounted(): void
|
||||
{
|
||||
// Le samedi reste hors périmètre (budget samedis dédié) : congé samedi toujours compté.
|
||||
$result = $this->countByCode([$this->buildAbsenceWithCode('2026-06-06', 'C')], ['C']);
|
||||
|
||||
self::assertSame(1.0, $result['count']);
|
||||
self::assertSame('06/06', $result['dates']);
|
||||
}
|
||||
|
||||
public function testWeekdayCongeCounted(): void
|
||||
{
|
||||
$result = $this->countByCode([$this->buildAbsenceWithCode('2026-06-01', 'C')], ['C']);
|
||||
|
||||
self::assertSame(1.0, $result['count']);
|
||||
self::assertSame('01/06', $result['dates']);
|
||||
}
|
||||
|
||||
public function testSundayMaladieStillCounted(): void
|
||||
{
|
||||
// L'exclusion du dimanche ne concerne que les congés (C) : maladie/AT inchangés.
|
||||
$result = $this->countByCode([$this->buildAbsenceWithCode('2026-06-07', 'M')], ['M', 'AT']);
|
||||
|
||||
self::assertSame(1.0, $result['count']);
|
||||
self::assertSame('07/06', $result['dates']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<Absence> $absences
|
||||
* @param list<string> $codes
|
||||
*
|
||||
* @return array{count: float, dates: string}
|
||||
*/
|
||||
private function countByCode(array $absences, array $codes): array
|
||||
{
|
||||
$provider = new ReflectionClass(SalaryRecapPrintProvider::class)->newInstanceWithoutConstructor();
|
||||
|
||||
return new ReflectionClass($provider::class)
|
||||
->getMethod('countAbsencesByCode')
|
||||
->invoke($provider, $absences, $codes)
|
||||
;
|
||||
}
|
||||
|
||||
private function buildAbsenceWithCode(string $date, string $code): Absence
|
||||
{
|
||||
return new Absence()
|
||||
->setType(new AbsenceType()->setCode($code)->setLabel($code)->setColor('#000'))
|
||||
->setStartDate(new DateTime($date))
|
||||
->setEndDate(new DateTime($date))
|
||||
->setStartHalf(HalfDay::AM)
|
||||
->setEndHalf(HalfDay::PM)
|
||||
;
|
||||
}
|
||||
|
||||
private function hasInRange(Employee $employee, string $from, string $to): bool
|
||||
{
|
||||
$provider = new ReflectionClass(SalaryRecapPrintProvider::class)->newInstanceWithoutConstructor();
|
||||
|
||||
return new ReflectionClass($provider::class)
|
||||
->getMethod('hasContractInRange')
|
||||
->invoke($provider, $employee, new DateTimeImmutable($from), new DateTimeImmutable($to));
|
||||
->invoke($provider, $employee, new DateTimeImmutable($from), new DateTimeImmutable($to))
|
||||
;
|
||||
}
|
||||
|
||||
private function buildEmployeeWithPeriod(string $start, ?string $end): Employee
|
||||
@@ -126,11 +190,13 @@ final class SalaryRecapPrintProviderTest extends TestCase
|
||||
{
|
||||
$provider = new ReflectionClass(SalaryRecapPrintProvider::class)->newInstanceWithoutConstructor();
|
||||
new ReflectionProperty(SalaryRecapPrintProvider::class, 'absenceSegmentsResolver')
|
||||
->setValue($provider, new AbsenceSegmentsResolver());
|
||||
->setValue($provider, new AbsenceSegmentsResolver())
|
||||
;
|
||||
|
||||
return new ReflectionClass($provider::class)
|
||||
->getMethod('splitForfaitCongesByN1')
|
||||
->invoke($provider, $conges, $budget, new DateTimeImmutable($from), new DateTimeImmutable($to));
|
||||
->invoke($provider, $conges, $budget, new DateTimeImmutable($from), new DateTimeImmutable($to))
|
||||
;
|
||||
}
|
||||
|
||||
private function buildConge(string $date): Absence
|
||||
|
||||
Reference in New Issue
Block a user