fix(pay-period): switch filters from categorie to type

This commit is contained in:
Matthieu Haineault 2025-08-29 13:16:58 -04:00
parent c52de6ecb8
commit c170481f3b

View File

@ -40,6 +40,7 @@ export class PayPeriodsQueryService {
} as any);
}
//find crew member associated with supervisor
private async resolveCrew(supervisor_id: number, include_subtree: boolean):
Promise<Array<{ id: number; first_name: string; last_name: string; email: string }>> {
const result: Array<{ id: number; first_name: string; last_name: string; email: string; }> = [];
@ -69,6 +70,7 @@ export class PayPeriodsQueryService {
return result;
}
//fetchs crew emails
async resolveCrewEmails(supervisor_id: number, include_subtree: boolean): Promise<Set<string>> {
const crew = await this.resolveCrew(supervisor_id, include_subtree);
return new Set(crew.map(crew_member => crew_member.email).filter(Boolean));
@ -161,7 +163,7 @@ export class PayPeriodsQueryService {
} },
},
},
bank_code: { select: { categorie: true } },
bank_code: { select: { categorie: true, type: true } },
},
});
@ -184,7 +186,7 @@ export class PayPeriodsQueryService {
} },
} },
} },
bank_code: { select: { categorie: true, modifier: true } },
bank_code: { select: { categorie: true, modifier: true, type: true } },
},
});
@ -230,12 +232,12 @@ 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?.categorie || "REGULAR").toUpperCase();
const categorie = (shift.bank_code?.type).toUpperCase();
switch (categorie) {
case "EVENING": record.evening_hours += hours; break;
case "EMERGENCY": record.emergency_hours += hours; break;
case "OVERTIME": record.overtime_hours += hours; break;
default: record.regular_hours += hours; break;
case "REGULAR" : record.regular_hours += hours; break;
}
record.is_approved = record.is_approved && shift.timesheet.is_approved;
}