From 8a2e67cbc8beae7d2b281586f599ba2883d0ffdc Mon Sep 17 00:00:00 2001 From: Matthieu Haineault Date: Wed, 14 Jan 2026 10:37:46 -0500 Subject: [PATCH] fix(banking): fix delete options of withdraw_banking hours --- .../domains/services/banking-hours.service.ts | 2 -- .../paid-time-off/paid-time-off.service.ts | 10 ++++++++-- .../shifts/services/shifts-delete.service.ts | 8 ++++++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/time-and-attendance/domains/services/banking-hours.service.ts b/src/time-and-attendance/domains/services/banking-hours.service.ts index 979ba0b..a336b93 100644 --- a/src/time-and-attendance/domains/services/banking-hours.service.ts +++ b/src/time-and-attendance/domains/services/banking-hours.service.ts @@ -65,9 +65,7 @@ export class BankedHoursService { } else { return { success: false, error: 'INVALID_SHIFT_TYPE' } as Result; } - }); - console.log('Banked hours: ', asked_hours); return result; } catch (error) { diff --git a/src/time-and-attendance/paid-time-off/paid-time-off.service.ts b/src/time-and-attendance/paid-time-off/paid-time-off.service.ts index 0012566..f239aa4 100644 --- a/src/time-and-attendance/paid-time-off/paid-time-off.service.ts +++ b/src/time-and-attendance/paid-time-off/paid-time-off.service.ts @@ -97,13 +97,19 @@ export class PaidTimeOFfBankHoursService { if (ajusted_hours < 0) ajusted_hours = 0; const config = paid_time_off_mapping[type]; - await this.prisma.paidTimeOff.update({ + console.log('even got in here!') + + const last_updated = new Date(); + console.log('config operation: ', config.operation, ' . config field: ', config.field, ' . Last updated: ', last_updated) + //the problem comes from this prisma query + const update = await this.prisma.paidTimeOff.update({ where: { employee_id }, data: { [config.field]: { [config.operation]: ajusted_hours }, - last_updated: new Date(), + last_updated: last_updated, }, }); + console.log('update infos: ', update); } } diff --git a/src/time-and-attendance/shifts/services/shifts-delete.service.ts b/src/time-and-attendance/shifts/services/shifts-delete.service.ts index e26b00c..9d96516 100644 --- a/src/time-and-attendance/shifts/services/shifts-delete.service.ts +++ b/src/time-and-attendance/shifts/services/shifts-delete.service.ts @@ -18,6 +18,7 @@ export class ShiftsDeleteService { //blocs deletion if approved async deleteShift(shift_id: number): Promise> { try { + console.log('shift id: ', shift_id) return await this.prisma.$transaction(async (tx) => { const shift = await tx.shifts.findUnique({ where: { id: shift_id }, @@ -31,17 +32,20 @@ export class ShiftsDeleteService { bank_code: { select: { type: true } }, }, }); + if (!shift) return { success: false, error: `SHIFT_NOT_FOUND` }; if (shift.is_approved) return { success: false, error: 'APPROUVED_SHIFT' }; - + console.log('got here') //call to ajust paid_time_off hour banks + + //this needs troubleshooting. returns try catch error message await this.paidTimeOffService.updatePaidTimeoffBankHoursWhenShiftDelete( shift.start_time, shift.end_time, shift.bank_code.type, shift.timesheet.employee_id ); - + console.log('also got here') await tx.shifts.delete({ where: { id: shift_id } }); return { success: true, data: shift.id }; });