From d004fa9fa2641370fa2234d211129939a2214da7 Mon Sep 17 00:00:00 2001 From: Matthieu Haineault Date: Tue, 17 Mar 2026 14:35:55 -0400 Subject: [PATCH] fix(csv): added evening, emergency, holiday and vacation hours in the overtime calculations --- .../exports/csv-exports.utils.ts | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/time-and-attendance/exports/csv-exports.utils.ts b/src/time-and-attendance/exports/csv-exports.utils.ts index 3b333e3..f48b6f4 100644 --- a/src/time-and-attendance/exports/csv-exports.utils.ts +++ b/src/time-and-attendance/exports/csv-exports.utils.ts @@ -3,6 +3,9 @@ import { HolidayService } from "src/time-and-attendance/domains/services/holiday import { CsvRow, InternalCsvRow } from "src/time-and-attendance/exports/export-csv-options.dto"; const REGULAR = 1; +const EVENING = 140; +const EMERGENCY = 48; +const HOLIDAY = 104; const OVERTIME = 43; const VACATION = 109; const SICK = 105; @@ -73,13 +76,30 @@ export const applyOvertimeRequalifications = ( } for (const [, rows] of grouped_rows) { + const evening_hours = rows.find(r => r.code === EVENING); + const emergency_hours = rows.find(r => r.code === EMERGENCY); + const holiday_hours = rows.find(r => r.code === HOLIDAY); const regular_hours = rows.find(r => r.code === REGULAR); + const vacation_hours = rows.find(r => r.code === VACATION); // if no regular hours row, push as is - if (!regular_hours?.quantite_hre) { result.push(...rows); continue; } + if ( + !regular_hours?.quantite_hre + || !evening_hours?.quantite_hre + || !emergency_hours?.quantite_hre + || !holiday_hours?.quantite_hre + || !vacation_hours?.quantite_hre + ) { result.push(...rows); continue; } + const total_hours = ( + regular_hours.quantite_hre + + evening_hours.quantite_hre + + emergency_hours.quantite_hre + + holiday_hours.quantite_hre + + vacation_hours.quantite_hre + ) // calculate overtime directly from consolidated regular hours - const overtime_hours = Math.max(0, regular_hours.quantite_hre - WEEKLY_LIMIT_HOURS); + const overtime_hours = Math.max(0, total_hours - WEEKLY_LIMIT_HOURS); // if no overtime, push as is if (overtime_hours <= 0) { result.push(...rows); continue; }