refactor(employees): added is_supervisor so the frontend can filter employees and use it in a select
This commit is contained in:
parent
9b4517a26d
commit
0c81f21f1b
|
|
@ -12,7 +12,7 @@ export class EmployeeDetailedDto {
|
|||
@IsEmail() @IsOptional() email: string;
|
||||
@IsString() phone_number: string;
|
||||
@IsDateString() first_work_day: string;
|
||||
@IsDateString() @IsOptional() last_work_day?: string;
|
||||
@IsDateString() @IsOptional() last_work_day?: string | null;
|
||||
@IsString() @IsOptional() residence?: string;
|
||||
@IsInt() @IsPositive() @Type(() => Number) external_payroll_id: number;
|
||||
@IsArray() @IsString({ each: true }) user_module_access: string[];
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import { EmailToIdResolver } from "src/common/mappers/email-id.mapper";
|
|||
import { toStringFromDate } from "src/common/utils/date-utils";
|
||||
import { Result } from "src/common/errors/result-error.factory";
|
||||
|
||||
import { toStringFromCompanyCode } from "src/identity-and-account/employees/utils/employee.utils";
|
||||
import { toCompanyCodeFromString, toStringFromCompanyCode } from "src/identity-and-account/employees/utils/employee.utils";
|
||||
import { EmployeeDetailedDto } from "src/identity-and-account/employees/dtos/employee-detailed.dto";
|
||||
import { EmployeeDto } from "src/identity-and-account/employees/dtos/employee.dto";
|
||||
|
||||
|
|
@ -37,6 +37,7 @@ export class EmployeesGetService {
|
|||
},
|
||||
},
|
||||
},
|
||||
is_supervisor: true,
|
||||
job_title: true,
|
||||
company_code: true,
|
||||
external_payroll_id: true,
|
||||
|
|
@ -50,6 +51,7 @@ export class EmployeesGetService {
|
|||
job_title: r.job_title ?? '',
|
||||
external_payroll_id: r.external_payroll_id,
|
||||
employee_full_name: `${r.user.first_name} ${r.user.last_name}`,
|
||||
is_supervisor: r.is_supervisor,
|
||||
supervisor_full_name: `${r.supervisor?.user.first_name} ${r.supervisor?.user.last_name}`,
|
||||
})),)
|
||||
return { success: true, data: employee_list }
|
||||
|
|
@ -75,6 +77,7 @@ export class EmployeesGetService {
|
|||
company_code: true,
|
||||
job_title: true,
|
||||
external_payroll_id: true,
|
||||
is_supervisor: true,
|
||||
supervisor: {
|
||||
select: {
|
||||
id: true, user: {
|
||||
|
|
@ -99,6 +102,7 @@ export class EmployeesGetService {
|
|||
company_name: company_name,
|
||||
job_title: existing_profile.job_title ?? '',
|
||||
external_payroll_id: existing_profile.external_payroll_id,
|
||||
is_supervisor: existing_profile.is_supervisor,
|
||||
phone_number: existing_profile.user.phone_number,
|
||||
residence: existing_profile.user.phone_number,
|
||||
first_work_day: toStringFromDate(existing_profile.first_work_day),
|
||||
|
|
@ -129,8 +133,8 @@ export class EmployeesGetService {
|
|||
personal_profile: true,
|
||||
timesheets: true,
|
||||
timesheets_approval: true,
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
supervisor: {
|
||||
|
|
@ -160,10 +164,8 @@ export class EmployeesGetService {
|
|||
module_access_array = toStringFromBoolean(employee.user.user_module_access);
|
||||
}
|
||||
|
||||
let company_name = 'Solucom';
|
||||
if (employee.company_code === 271583) {
|
||||
company_name = 'Targo';
|
||||
}
|
||||
const company_name = toStringFromCompanyCode(employee.company_code);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
data: {
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ export class EmployeesUpdateService {
|
|||
const company_code = toCompanyCodeFromString(dto.company_name);
|
||||
const supervisor_id = await this.toIdFromFullName(dto.supervisor_full_name);
|
||||
const normalized_access = await toBooleanFromString(dto.user_module_access);
|
||||
const last_work_day = dto.last_work_day ? toDateFromString(dto.last_work_day) : null;
|
||||
|
||||
await this.prisma.$transaction(async (tx) => {
|
||||
await tx.users.update({
|
||||
|
|
@ -61,7 +62,7 @@ export class EmployeesUpdateService {
|
|||
company_code: company_code,
|
||||
job_title: dto.job_title,
|
||||
first_work_day: toDateFromString(dto.first_work_day),
|
||||
last_work_day: dto.last_work_day,
|
||||
last_work_day: last_work_day,
|
||||
is_supervisor: dto.is_supervisor,
|
||||
supervisor_id: supervisor_id,
|
||||
schedule_preset_id: dto.preset_id,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user