fix(banking): fix an issue where the banked hours would not be updated as intended
This commit is contained in:
parent
6c89acbe0e
commit
1abc377891
|
|
@ -32,7 +32,7 @@ export class BankedHoursService {
|
||||||
return { success: false, error: 'BANKING_HOURS_BANK_NOT_FOUND' } as Result<number, string>;
|
return { success: false, error: 'BANKING_HOURS_BANK_NOT_FOUND' } as Result<number, string>;
|
||||||
}
|
}
|
||||||
const banked_hours = (employee.paid_time_off.banked_hours).toNumber();
|
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<number, string>;
|
return { success: false, error: 'EMPTY_BANKED_HOURS' } as Result<number, string>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -67,6 +67,7 @@ export class BankedHoursService {
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
console.log('Banked hours: ', asked_hours);
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
|
||||||
|
|
@ -94,6 +94,7 @@ export class PaidTimeOFfBankHoursService {
|
||||||
if (type === 'BANKING') {
|
if (type === 'BANKING') {
|
||||||
ajusted_hours = ajusted_hours * 1.5;
|
ajusted_hours = ajusted_hours * 1.5;
|
||||||
}
|
}
|
||||||
|
if (ajusted_hours < 0) ajusted_hours = 0;
|
||||||
|
|
||||||
const config = paid_time_off_mapping[type];
|
const config = paid_time_off_mapping[type];
|
||||||
await this.prisma.paidTimeOff.update({
|
await this.prisma.paidTimeOff.update({
|
||||||
|
|
|
||||||
|
|
@ -132,7 +132,7 @@ export class ShiftsCreateService {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!result.success) return { success: false, error: result.error };
|
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 = new Date(normed_shift.data.start_time);
|
||||||
adjusted_end_time.setHours(adjusted_end_time.getHours() + valid_hours);
|
adjusted_end_time.setHours(adjusted_end_time.getHours() + valid_hours);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user