fix(paid-time-off): add expected daily hours to timesheet output.
This commit is contained in:
parent
40fa274571
commit
2936b84b47
|
|
@ -54,7 +54,7 @@ export class GetTimesheetsOverviewService {
|
||||||
//find user infos using the employee_id
|
//find user infos using the employee_id
|
||||||
const employee = await this.prisma.employees.findUnique({
|
const employee = await this.prisma.employees.findUnique({
|
||||||
where: { id: employee_id.data },
|
where: { id: employee_id.data },
|
||||||
include: { schedule_preset: true, user: true },
|
select: { daily_expected_hours: true, schedule_preset: true, user: true },
|
||||||
});
|
});
|
||||||
if (!employee) return { success: false, error: `EMPLOYEE_NOT_FOUND` }
|
if (!employee) return { success: false, error: `EMPLOYEE_NOT_FOUND` }
|
||||||
|
|
||||||
|
|
@ -68,7 +68,14 @@ export class GetTimesheetsOverviewService {
|
||||||
const timesheets = await Promise.all(rows.map((timesheet) => mapOneTimesheet(timesheet)));
|
const timesheets = await Promise.all(rows.map((timesheet) => mapOneTimesheet(timesheet)));
|
||||||
if (!timesheets) return { success: false, error: 'INVALID_TIMESHEET' }
|
if (!timesheets) return { success: false, error: 'INVALID_TIMESHEET' }
|
||||||
|
|
||||||
return { success: true, data: { has_preset_schedule, employee_fullname, timesheets } };
|
const data: Timesheets = {
|
||||||
|
has_preset_schedule,
|
||||||
|
employee_fullname,
|
||||||
|
daily_expected_hours: employee.daily_expected_hours,
|
||||||
|
timesheets,
|
||||||
|
}
|
||||||
|
|
||||||
|
return { success: true, data };
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
return { success: false, error: 'TIMESHEET_NOT_FOUND' }
|
return { success: false, error: 'TIMESHEET_NOT_FOUND' }
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ export class TimesheetEntity {
|
||||||
export class Timesheets {
|
export class Timesheets {
|
||||||
@IsBoolean() has_preset_schedule: boolean;
|
@IsBoolean() has_preset_schedule: boolean;
|
||||||
@IsString() employee_fullname: string;
|
@IsString() employee_fullname: string;
|
||||||
|
@IsInt() daily_expected_hours: number;
|
||||||
@Type(() => Timesheet) timesheets: Timesheet[];
|
@Type(() => Timesheet) timesheets: Timesheet[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user