fix(presets): simplify process of updating employee profiles with deleted preset.
Also removed superfluous prints that are no longer required in certain modules (testing)
This commit is contained in:
parent
313a1e5fb6
commit
93b974c160
|
|
@ -323,7 +323,7 @@ model Preferences {
|
|||
|
||||
view PayPeriods {
|
||||
pay_year Int
|
||||
pay_period_no BigInt
|
||||
pay_period_no Int
|
||||
period_start DateTime @db.Date
|
||||
period_end DateTime @db.Date
|
||||
payday DateTime @db.Date
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ export class EmployeeTimesheetResolver {
|
|||
const employee_id = await this.emailResolver.findIdByEmail(email);
|
||||
if (!employee_id.success) return { success: false, error: employee_id.error }
|
||||
const start_date = weekStartSunday(date);
|
||||
console.log('start date: ', start_date);
|
||||
const timesheet = await db.timesheets.findFirst({
|
||||
where: { employee_id: employee_id.data, start_date: start_date },
|
||||
select: { id: true },
|
||||
|
|
|
|||
|
|
@ -14,17 +14,14 @@ export class SchedulePresetDeleteService {
|
|||
});
|
||||
if (!preset) return { success: false, error: `SCHEDULE_PRESET_NOT_FOUND` };
|
||||
|
||||
const employee_with_preset = await this.prisma.employees.findMany({
|
||||
await this.prisma.employees.updateMany({
|
||||
where: { schedule_preset_id: preset.id },
|
||||
select: {
|
||||
schedule_preset_id: true,
|
||||
data: {
|
||||
schedule_preset_id: null,
|
||||
},
|
||||
|
||||
});
|
||||
if(employee_with_preset.length > 0) {
|
||||
for(const employee of employee_with_preset) {
|
||||
employee.schedule_preset_id = null;
|
||||
}
|
||||
}
|
||||
|
||||
await this.prisma.$transaction(async (tx) => {
|
||||
await tx.schedulePresetShifts.deleteMany({ where: { preset_id: preset_id } });
|
||||
await tx.schedulePresets.delete({ where: { id: preset_id } });
|
||||
|
|
|
|||
|
|
@ -64,7 +64,6 @@ export class ShiftsUpdateService {
|
|||
if (!timesheet.success) return { success: false, error: timesheet.error }
|
||||
|
||||
//finds original shift
|
||||
console.log('timesheet id found: ', timesheet.data.id);
|
||||
const original = await this.prisma.shifts.findFirst({
|
||||
where: { id: dto.id, timesheet_id: timesheet.data.id },
|
||||
select: shift_select,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user