feat(paid_time_off): added last_updated to manipulations bank updates
This commit is contained in:
parent
7e9dbe5b3d
commit
5d6f6bfd0a
|
|
@ -39,7 +39,10 @@ export class BankedHoursService {
|
||||||
if (type === 'BANKING') {
|
if (type === 'BANKING') {
|
||||||
const new_balance = await tx.paidTimeOff.update({
|
const new_balance = await tx.paidTimeOff.update({
|
||||||
where: { employee_id: employee.id },
|
where: { employee_id: employee.id },
|
||||||
data: { banked_hours: { increment: asked_hours } },
|
data: {
|
||||||
|
banked_hours: { increment: asked_hours },
|
||||||
|
last_updated: new Date(),
|
||||||
|
},
|
||||||
select: { banked_hours: true },
|
select: { banked_hours: true },
|
||||||
});
|
});
|
||||||
return { success: true, data: (new_balance.banked_hours).toNumber() } as Result<number, string>;
|
return { success: true, data: (new_balance.banked_hours).toNumber() } as Result<number, string>;
|
||||||
|
|
@ -52,7 +55,10 @@ export class BankedHoursService {
|
||||||
}
|
}
|
||||||
await tx.paidTimeOff.update({
|
await tx.paidTimeOff.update({
|
||||||
where: { employee_id: employee.id },
|
where: { employee_id: employee.id },
|
||||||
data: { banked_hours: { decrement: asked_hours } },
|
data: {
|
||||||
|
banked_hours: { decrement: asked_hours },
|
||||||
|
last_updated: new Date(),
|
||||||
|
},
|
||||||
select: { banked_hours: true },
|
select: { banked_hours: true },
|
||||||
});
|
});
|
||||||
return { success: true, data: asked_hours } as Result<number, string>;
|
return { success: true, data: asked_hours } as Result<number, string>;
|
||||||
|
|
|
||||||
|
|
@ -142,7 +142,10 @@ export class SickLeaveService {
|
||||||
} else {
|
} else {
|
||||||
await tx.paidTimeOff.update({
|
await tx.paidTimeOff.update({
|
||||||
where: { employee_id: employee.id },
|
where: { employee_id: employee.id },
|
||||||
data: { banked_hours: { decrement: asked_hours } },
|
data: {
|
||||||
|
banked_hours: { decrement: asked_hours },
|
||||||
|
last_updated: new Date(),
|
||||||
|
},
|
||||||
select: { banked_hours: true },
|
select: { banked_hours: true },
|
||||||
});
|
});
|
||||||
return { success: true, data: asked_hours } as Result<number, string>;
|
return { success: true, data: asked_hours } as Result<number, string>;
|
||||||
|
|
|
||||||
|
|
@ -101,6 +101,7 @@ export class VacationService {
|
||||||
where: { employee_id: employee_id, vacation_hours: { gte: asked_hours } },
|
where: { employee_id: employee_id, vacation_hours: { gte: asked_hours } },
|
||||||
data: {
|
data: {
|
||||||
vacation_hours: { decrement: asked_hours },
|
vacation_hours: { decrement: asked_hours },
|
||||||
|
last_updated: new Date(),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
//returns asked hours if enough hours are left in the bank
|
//returns asked hours if enough hours are left in the bank
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,10 @@ export class PaidTimeOFfBankHoursService {
|
||||||
|
|
||||||
await this.prisma.paidTimeOff.update({
|
await this.prisma.paidTimeOff.update({
|
||||||
where: { employee_id },
|
where: { employee_id },
|
||||||
data: { [config.field]: { [operation]: hours } },
|
data: {
|
||||||
|
[config.field]: { [operation]: hours },
|
||||||
|
last_updated: new Date(),
|
||||||
|
},
|
||||||
});
|
});
|
||||||
return { success: true, data: true };
|
return { success: true, data: true };
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
@ -88,6 +91,7 @@ export class PaidTimeOFfBankHoursService {
|
||||||
where: { employee_id },
|
where: { employee_id },
|
||||||
data: {
|
data: {
|
||||||
[config.field]: { [config.operation]: ajusted_hours },
|
[config.field]: { [config.operation]: ajusted_hours },
|
||||||
|
last_updated: new Date(),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user