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:
Nicolas Drolet 2025-12-12 13:33:27 -05:00
parent 313a1e5fb6
commit 93b974c160
4 changed files with 6 additions and 11 deletions

View File

@ -323,7 +323,7 @@ model Preferences {
view PayPeriods { view PayPeriods {
pay_year Int pay_year Int
pay_period_no BigInt pay_period_no Int
period_start DateTime @db.Date period_start DateTime @db.Date
period_end DateTime @db.Date period_end DateTime @db.Date
payday DateTime @db.Date payday DateTime @db.Date

View File

@ -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 },

View File

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

View File

@ -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,