Merge branch 'main' of git.targo.ca:Targo/targo_backend
This commit is contained in:
commit
c03ea4cb6f
|
|
@ -27,6 +27,7 @@ export class EmployeePeriodOverviewDto {
|
|||
holiday_hours: number;
|
||||
vacation_hours: number;
|
||||
};
|
||||
weekly_hours: number[];
|
||||
total_hours: number;
|
||||
expenses: number;
|
||||
mileage: number;
|
||||
|
|
|
|||
|
|
@ -116,6 +116,8 @@ export class GetOverviewService {
|
|||
);
|
||||
|
||||
for (const timesheet of employee.timesheet) {
|
||||
let total_weekly_hours: number = 0;
|
||||
|
||||
//totals by types for shifts
|
||||
for (const shift of timesheet.shift) {
|
||||
const hours = computeHours(shift.start_time, shift.end_time);
|
||||
|
|
@ -123,24 +125,27 @@ export class GetOverviewService {
|
|||
switch (type) {
|
||||
case "EVENING": record.other_hours.evening_hours += hours;
|
||||
record.total_hours += hours;
|
||||
total_weekly_hours += hours;
|
||||
break;
|
||||
case "EMERGENCY": record.other_hours.emergency_hours += hours;
|
||||
record.total_hours += hours;
|
||||
total_weekly_hours += hours;
|
||||
break;
|
||||
case "OVERTIME": record.other_hours.overtime_hours += hours;
|
||||
record.total_hours += hours;
|
||||
total_weekly_hours += hours;
|
||||
break;
|
||||
case "SICK": record.other_hours.sick_hours += hours;
|
||||
record.total_hours += hours;
|
||||
break;
|
||||
case "HOLIDAY": record.other_hours.holiday_hours += hours;
|
||||
record.total_hours += hours;
|
||||
total_weekly_hours += hours;
|
||||
break;
|
||||
case "VACATION": record.other_hours.vacation_hours += hours;
|
||||
record.total_hours += hours;
|
||||
break;
|
||||
case "REGULAR": record.regular_hours += hours;
|
||||
record.total_hours += hours;
|
||||
total_weekly_hours += hours;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -155,6 +160,8 @@ export class GetOverviewService {
|
|||
record.mileage = Number((record.mileage += Math.round(mileage)).toFixed(2));
|
||||
}
|
||||
}
|
||||
|
||||
record.weekly_hours.push(total_weekly_hours);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -214,6 +221,7 @@ export class GetOverviewService {
|
|||
holiday_hours: 0,
|
||||
vacation_hours: 0,
|
||||
},
|
||||
weekly_hours: [],
|
||||
total_hours: 0,
|
||||
expenses: 0,
|
||||
mileage: 0,
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ export class GetTimesheetsOverviewService {
|
|||
const has_existing_timesheets = rows.some(
|
||||
(row) => toDateFromString(row.start_date).getTime() === week_start.getTime()
|
||||
);
|
||||
if (!has_existing_timesheets) this.ensureTimesheet(employee_id.data, week_start);
|
||||
if (!has_existing_timesheets) await this.ensureTimesheet(employee_id.data, week_start);
|
||||
}
|
||||
rows = await this.loadTimesheets(employee_id.data, period.period_start, period.period_end);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user