From 1abc377891d92e7185e2890706c080b69a03280f Mon Sep 17 00:00:00 2001 From: Matthieu Haineault Date: Wed, 14 Jan 2026 08:20:27 -0500 Subject: [PATCH] fix(banking): fix an issue where the banked hours would not be updated as intended --- .../domains/services/banking-hours.service.ts | 3 ++- src/time-and-attendance/paid-time-off/paid-time-off.service.ts | 1 + .../shifts/services/shifts-create.service.ts | 2 +- 3 files changed, 4 insertions(+), 2 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 1a94b91..979ba0b 100644 --- a/src/time-and-attendance/domains/services/banking-hours.service.ts +++ b/src/time-and-attendance/domains/services/banking-hours.service.ts @@ -32,7 +32,7 @@ export class BankedHoursService { return { success: false, error: 'BANKING_HOURS_BANK_NOT_FOUND' } as Result; } const banked_hours = (employee.paid_time_off.banked_hours).toNumber(); - if (banked_hours <= 0) { + if (banked_hours <= 0 && type === 'WITHDRAW_BANKED') { return { success: false, error: 'EMPTY_BANKED_HOURS' } as Result; } @@ -67,6 +67,7 @@ export class BankedHoursService { } }); + 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 8aacb60..0012566 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 @@ -94,6 +94,7 @@ export class PaidTimeOFfBankHoursService { if (type === 'BANKING') { ajusted_hours = ajusted_hours * 1.5; } + if (ajusted_hours < 0) ajusted_hours = 0; const config = paid_time_off_mapping[type]; await this.prisma.paidTimeOff.update({ diff --git a/src/time-and-attendance/shifts/services/shifts-create.service.ts b/src/time-and-attendance/shifts/services/shifts-create.service.ts index c4e9c83..9482525 100644 --- a/src/time-and-attendance/shifts/services/shifts-create.service.ts +++ b/src/time-and-attendance/shifts/services/shifts-create.service.ts @@ -132,7 +132,7 @@ export class ShiftsCreateService { } if (!result.success) return { success: false, error: result.error }; - const valid_hours = result.data; + const valid_hours = result.data / 1.5; adjusted_end_time = new Date(normed_shift.data.start_time); adjusted_end_time.setHours(adjusted_end_time.getHours() + valid_hours); }