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

@@ -19,13 +19,12 @@ final class EmployeeRttPaymentRepository extends ServiceEntityRepository
parent::__construct($registry, EmployeeRttPayment::class);
}
public function findOneByEmployeeYearMonthRate(Employee $employee, int $year, int $month, string $rate): ?EmployeeRttPayment
public function findOneByEmployeeYearMonth(Employee $employee, int $year, int $month): ?EmployeeRttPayment
{
return $this->findOneBy([
'employee' => $employee,
'year' => $year,
'month' => $month,
'rate' => $rate,
]);
}

View File

@@ -139,29 +139,40 @@ final class WorkHourRepository extends ServiceEntityRepository implements WorkHo
}
/**
* @return array<string, float> YYYY-MM => presence day count (0.5 for half-days)
* Count weekend worked days by month.
* >= 5h total = 1.0 day, < 5h = 0.5 day.
*
* @return array<string, float> YYYY-MM => weekend worked day count
*/
public function countPresenceDaysByMonth(Employee $employee, DateTimeImmutable $from, DateTimeImmutable $to): array
public function countWeekendWorkedDaysByMonth(Employee $employee, DateTimeImmutable $from, DateTimeImmutable $to): array
{
$sql = <<<'SQL'
SELECT TO_CHAR(work_date, 'YYYY-MM') AS month,
SUM(
CASE
WHEN (morning_from IS NOT NULL OR is_present_morning = true)
AND (afternoon_from IS NOT NULL OR is_present_afternoon = true)
THEN 1.0
WHEN (morning_from IS NOT NULL OR is_present_morning = true)
OR (afternoon_from IS NOT NULL OR is_present_afternoon = true)
THEN 0.5
WHEN total_minutes >= 300 THEN 1.0
WHEN total_minutes > 0 THEN 0.5
ELSE 0
END
) AS cnt
FROM work_hours
WHERE employee_id = :employee
AND work_date >= :from
AND work_date <= :to
AND (morning_from IS NOT NULL OR is_present_morning = true
OR afternoon_from IS NOT NULL OR is_present_afternoon = true)
FROM (
SELECT work_date,
COALESCE(
EXTRACT(EPOCH FROM (morning_to::time - morning_from::time)) / 60, 0
)
+ COALESCE(
EXTRACT(EPOCH FROM (afternoon_to::time - afternoon_from::time)) / 60, 0
)
+ COALESCE(
EXTRACT(EPOCH FROM (evening_to::time - evening_from::time)) / 60, 0
) AS total_minutes
FROM work_hours
WHERE employee_id = :employee
AND work_date >= :from
AND work_date <= :to
AND EXTRACT(ISODOW FROM work_date) IN (6, 7)
AND (morning_from IS NOT NULL OR afternoon_from IS NOT NULL OR evening_from IS NOT NULL)
) sub
GROUP BY month
SQL;