From 70b7809079be56af2c2c2ff46b916e8b1860f924 Mon Sep 17 00:00:00 2001 From: tristan Date: Thu, 11 Jun 2026 17:17:02 +0200 Subject: [PATCH] =?UTF-8?q?feat(overtime-contingent)=20:=20endpoint=20lect?= =?UTF-8?q?ure=20contingent=20fiche=20employ=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 4.6 --- .../EmployeeOvertimeContingent.php | 27 +++++++++ .../EmployeeOvertimeContingentProvider.php | 60 +++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 src/ApiResource/EmployeeOvertimeContingent.php create mode 100644 src/State/EmployeeOvertimeContingentProvider.php diff --git a/src/ApiResource/EmployeeOvertimeContingent.php b/src/ApiResource/EmployeeOvertimeContingent.php new file mode 100644 index 0000000..eceda1a --- /dev/null +++ b/src/ApiResource/EmployeeOvertimeContingent.php @@ -0,0 +1,27 @@ +employeeRepository->find($employeeId); + if (!$employee instanceof Employee) { + throw new NotFoundHttpException('Employee not found.'); + } + + $request = $this->requestStack->getCurrentRequest(); + $year = (int) $request?->query->get('year', (string) (int) new DateTimeImmutable('now')->format('Y')); + if ($year < 2000 || $year > 2100) { + throw new UnprocessableEntityHttpException('year must be between 2000 and 2100.'); + } + + // Année civile Y = exercice Y (mois 1-5) + exercice Y+1 (mois 6-12). + $payments = array_merge( + $this->rttPaymentRepository->findByEmployeeAndYear($employee, $year), + $this->rttPaymentRepository->findByEmployeeAndYear($employee, $year + 1), + ); + + $output = new EmployeeOvertimeContingent(); + $output->year = $year; + $output->paidMinutes = $this->calculator->totalBaseMinutes($payments, $year); + $output->isDriver = $employee->getIsDriver(); + $output->capHours = $this->calculator->capHours($output->isDriver); + + return $output; + } +}