feat : Ajout du système de RTT sur la page employé avec le repport annuel des heures
All checks were successful
Auto Tag Develop / tag (push) Successful in 6s

This commit is contained in:
2026-03-13 10:26:33 +01:00
parent 1858817649
commit 4a2c3a8eed
29 changed files with 1595 additions and 391 deletions

View File

@@ -16,8 +16,6 @@ use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException;
use function in_array;
final readonly class EmployeeRttPaymentProcessor implements ProcessorInterface
{
public function __construct(
@@ -42,32 +40,27 @@ final readonly class EmployeeRttPaymentProcessor implements ProcessorInterface
throw new NotFoundHttpException('Employee not found.');
}
if (!in_array($data->rate, ['25', '50'], true)) {
throw new UnprocessableEntityHttpException('rate must be "25" or "50".');
}
if ($data->month < 1 || $data->month > 12) {
throw new UnprocessableEntityHttpException('month must be between 1 and 12.');
}
if ($data->minutes < 0) {
throw new UnprocessableEntityHttpException('minutes must be >= 0.');
}
$year = $data->year ?? $this->resolveCurrentExerciseYear();
$payment = $this->rttPaymentRepository->findOneByEmployeeYearMonthRate($employee, $year, $data->month, $data->rate);
$payment = $this->rttPaymentRepository->findOneByEmployeeYearMonth($employee, $year, $data->month);
if (null === $payment) {
$payment = new EmployeeRttPayment();
$payment->setEmployee($employee);
$payment->setYear($year);
$payment->setMonth($data->month);
$payment->setRate($data->rate);
$this->entityManager->persist($payment);
}
$payment->setMinutes($data->minutes);
$payment->setBase25Minutes($data->base25Minutes);
$payment->setBonus25Minutes($data->bonus25Minutes);
$payment->setBase50Minutes($data->base50Minutes);
$payment->setBonus50Minutes($data->bonus50Minutes);
$payment->touch();
$this->entityManager->flush();
$data->year = $year;