fix(csv): added evening, emergency, holiday and vacation hours in the overtime calculations
This commit is contained in:
parent
b25558d71c
commit
d004fa9fa2
|
|
@ -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; }
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user