fix(holiday): fixed the valid codes for the holiday calculations

This commit is contained in:
Matthieu Haineault 2026-03-17 14:42:17 -04:00
parent d004fa9fa2
commit b1069c0add

View File

@ -30,23 +30,16 @@ export class HolidayService {
holiday_date: Date holiday_date: Date
): Promise<Result<number, string>> { ): Promise<Result<number, string>> {
try { try {
const valid_codes = ['G1', 'G43', 'G140', 'G104', 'G105', 'G305', 'G700', 'G720']; const valid_codes = ['G1', 'G43', 'G48', 'G104', 'G105', 'G109', 'G140', 'G720'];
const holiday_week_start = getWeekStart(holiday_date); const holiday_week_start = getWeekStart(holiday_date);
const window_start = new Date(holiday_week_start.getTime() - 4 * MS_PER_WEEK); const window_start = new Date(holiday_week_start.getTime() - 4 * MS_PER_WEEK);
const window_end = new Date(holiday_week_start.getTime() - 1); const window_end = new Date(holiday_week_start.getTime() - 1);
const employee = await this.prisma.employees.findFirst({ const employee = await this.prisma.employees.findFirst({
where: { where: { external_payroll_id, company_code }
external_payroll_id,
company_code,
},
select: {
id: true,
}
}); });
if (!employee) if (!employee) return { success: false, error: 'EMPLOYEE_NOT_FOUND' };
return { success: false, error: 'EMPLOYEE_NOT_FOUND' };
const shifts = await this.prisma.shifts.findMany({ const shifts = await this.prisma.shifts.findMany({
where: { where: {
@ -61,8 +54,7 @@ export class HolidayService {
for (const shift of shifts) { for (const shift of shifts) {
const hours = computeHours(shift.start_time, shift.end_time); const hours = computeHours(shift.start_time, shift.end_time);
if (hours <= 0) if (hours <= 0) continue;
continue;
const shift_week_start = getWeekStart(shift.date); const shift_week_start = getWeekStart(shift.date);
const key = shift_week_start.getTime(); const key = shift_week_start.getTime();