fix(banking): fix delete options of withdraw_banking hours

This commit is contained in:
Matthieu Haineault 2026-01-14 10:37:46 -05:00
parent 456f69baa4
commit 8a2e67cbc8
3 changed files with 14 additions and 6 deletions

View File

@ -65,9 +65,7 @@ export class BankedHoursService {
} else {
return { success: false, error: 'INVALID_SHIFT_TYPE' } as Result<number, string>;
}
});
console.log('Banked hours: ', asked_hours);
return result;
} catch (error) {

View File

@ -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);
}
}

View File

@ -18,6 +18,7 @@ export class ShiftsDeleteService {
//blocs deletion if approved
async deleteShift(shift_id: number): Promise<Result<number, string>> {
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 };
});