Merge branch 'main' of git.targo.ca:Targo/targo_backend
This commit is contained in:
commit
9a8dcbccc3
|
|
@ -20,7 +20,6 @@ export class EmployeeTimesheetResolver {
|
||||||
const employee_id = await this.emailResolver.findIdByEmail(email);
|
const employee_id = await this.emailResolver.findIdByEmail(email);
|
||||||
if (!employee_id.success) return { success: false, error: employee_id.error }
|
if (!employee_id.success) return { success: false, error: employee_id.error }
|
||||||
const start_date = weekStartSunday(date);
|
const start_date = weekStartSunday(date);
|
||||||
console.log('start date: ', start_date);
|
|
||||||
const timesheet = await db.timesheets.findFirst({
|
const timesheet = await db.timesheets.findFirst({
|
||||||
where: { employee_id: employee_id.data, start_date: start_date },
|
where: { employee_id: employee_id.data, start_date: start_date },
|
||||||
select: { id: true },
|
select: { id: true },
|
||||||
|
|
|
||||||
|
|
@ -14,17 +14,14 @@ export class SchedulePresetDeleteService {
|
||||||
});
|
});
|
||||||
if (!preset) return { success: false, error: `SCHEDULE_PRESET_NOT_FOUND` };
|
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 },
|
where: { schedule_preset_id: preset.id },
|
||||||
select: {
|
data: {
|
||||||
schedule_preset_id: true,
|
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 this.prisma.$transaction(async (tx) => {
|
||||||
await tx.schedulePresetShifts.deleteMany({ where: { preset_id: preset_id } });
|
await tx.schedulePresetShifts.deleteMany({ where: { preset_id: preset_id } });
|
||||||
await tx.schedulePresets.delete({ where: { 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 }
|
if (!timesheet.success) return { success: false, error: timesheet.error }
|
||||||
|
|
||||||
//finds original shift
|
//finds original shift
|
||||||
console.log('timesheet id found: ', timesheet.data.id);
|
|
||||||
const original = await this.prisma.shifts.findFirst({
|
const original = await this.prisma.shifts.findFirst({
|
||||||
where: { id: dto.id, timesheet_id: timesheet.data.id },
|
where: { id: dto.id, timesheet_id: timesheet.data.id },
|
||||||
select: shift_select,
|
select: shift_select,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user