feat(pay-periods): added total_hours and is_remote to payload
This commit is contained in:
parent
0fb6465c27
commit
8ef5c0ac11
|
|
@ -30,6 +30,8 @@ export class EmployeePeriodOverviewDto {
|
|||
@ApiProperty({ example: 2, description: 'pay-period`s overtime hours' })
|
||||
overtime_hours: number;
|
||||
|
||||
total_hours: number;
|
||||
|
||||
@ApiProperty({ example: 420.69, description: 'pay-period`s total expenses ($)' })
|
||||
expenses: number;
|
||||
|
||||
|
|
|
|||
|
|
@ -203,6 +203,7 @@ export class PayPeriodsQueryService {
|
|||
evening_hours: 0,
|
||||
emergency_hours: 0,
|
||||
overtime_hours: 0,
|
||||
total_hours: 0,
|
||||
expenses: 0,
|
||||
mileage: 0,
|
||||
is_approved: true,
|
||||
|
|
@ -220,6 +221,7 @@ export class PayPeriodsQueryService {
|
|||
evening_hours: 0,
|
||||
emergency_hours: 0,
|
||||
overtime_hours: 0,
|
||||
total_hours: 0,
|
||||
expenses: 0,
|
||||
mileage: 0,
|
||||
is_approved: true,
|
||||
|
|
@ -235,14 +237,16 @@ export class PayPeriodsQueryService {
|
|||
const record = ensure(employee.id, name, employee.user.email);
|
||||
|
||||
const hours = computeHours(shift.start_time, shift.end_time);
|
||||
const categorie = (shift.bank_code?.type).toUpperCase();
|
||||
switch (categorie) {
|
||||
const type = (shift.bank_code?.type ?? '').toUpperCase();
|
||||
switch (type) {
|
||||
case "EVENING": record.evening_hours += hours; break;
|
||||
case "EMERGENCY": record.emergency_hours += hours; break;
|
||||
case "OVERTIME": record.overtime_hours += hours; break;
|
||||
case "REGULAR" : record.regular_hours += hours; break;
|
||||
}
|
||||
record.is_approved = record.is_approved && shift.timesheet.is_approved;
|
||||
record.total_hours += hours;
|
||||
record.is_remote = record.is_remote || !!shift.is_remote;
|
||||
}
|
||||
|
||||
for (const expense of expenses) {
|
||||
|
|
@ -259,10 +263,10 @@ export class PayPeriodsQueryService {
|
|||
record.mileage += Math.round((amount / rate)/100)*100;
|
||||
}
|
||||
record.is_approved = record.is_approved && expense.timesheet.is_approved;
|
||||
}
|
||||
}
|
||||
|
||||
const employees_overview = Array.from(by_employee.values()).sort((a, b) =>
|
||||
a.employee_name.localeCompare(b.employee_name, "fr", { sensitivity: "base" }),
|
||||
const employees_overview = Array.from(by_employee.values()).sort((a, b) =>
|
||||
a.employee_name.localeCompare(b.employee_name, "fr", { sensitivity: "base" }),
|
||||
);
|
||||
|
||||
return {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user