diff --git a/src/time-and-attendance/timesheets/services/timesheet-get-overview.service.ts b/src/time-and-attendance/timesheets/services/timesheet-get-overview.service.ts index 541dd82..1e44393 100644 --- a/src/time-and-attendance/timesheets/services/timesheet-get-overview.service.ts +++ b/src/time-and-attendance/timesheets/services/timesheet-get-overview.service.ts @@ -71,11 +71,12 @@ export class GetTimesheetsOverviewService { //find user infos using the employee_id const employee = await this.prisma.employees.findUnique({ where: { id: employee_id.data }, - include: { user: true }, + include: { schedule_preset: true, user: true }, }); if (!employee) return { success: false, error: `EMPLOYEE_NOT_FOUND` } - //builds employee full name + //builds employee details + const has_preset_schedule = employee.schedule_preset !== null; const user = employee.user; const employee_fullname = `${user.first_name} ${user.last_name}`.trim(); @@ -84,7 +85,7 @@ export class GetTimesheetsOverviewService { const timesheets = await Promise.all(rows.map((timesheet) => this.mapOneTimesheet(timesheet))); if (!timesheets) return { success: false, error: 'INVALID_TIMESHEET' } - return { success: true, data: { employee_fullname, timesheets } }; + return { success: true, data: { has_preset_schedule, employee_fullname, timesheets } }; } catch (error) { return { success: false, error: 'TIMESHEET_NOT_FOUND' } } @@ -100,7 +101,7 @@ export class GetTimesheetsOverviewService { include: { employee: { include: { user: true } }, shift: { include: { bank_code: true }, orderBy: { start_time: 'asc' } }, - expense: { include: { bank_code: true, attachment_record: true }, orderBy: [{ date: 'asc' }, {bank_code_id: 'desc'}] }, + expense: { include: { bank_code: true, attachment_record: true }, orderBy: [{ date: 'asc' }, { bank_code_id: 'desc' }] }, }, orderBy: { start_date: 'asc' }, }); diff --git a/src/time-and-attendance/timesheets/timesheet.dto.ts b/src/time-and-attendance/timesheets/timesheet.dto.ts index 9858077..61055a0 100644 --- a/src/time-and-attendance/timesheets/timesheet.dto.ts +++ b/src/time-and-attendance/timesheets/timesheet.dto.ts @@ -9,6 +9,7 @@ export class TimesheetEntity { } export class Timesheets { + @IsBoolean() has_preset_schedule: boolean; @IsString() employee_fullname: string; @Type(() => Timesheet) timesheets: Timesheet[]; }