Merge branch 'main' of git.targo.ca:Targo/targo_backend

This commit is contained in:
Matthieu Haineault 2026-01-09 12:01:11 -05:00
commit 25c9e0a673
3 changed files with 214 additions and 184 deletions

View File

@ -1,5 +1,6 @@
import { IsArray, IsBoolean, IsDateString, IsEmail, IsInt, IsNotEmpty, IsOptional, IsPositive, IsString } from 'class-validator'; import { IsArray, IsBoolean, IsDateString, IsEmail, IsInt, IsNotEmpty, IsOptional, IsPositive, IsString } from 'class-validator';
import { Type } from 'class-transformer'; import { Type } from 'class-transformer';
import { PaidTimeOffDto } from 'src/time-and-attendance/domains/paid-time-off.dto';
export class EmployeeDetailedDto { export class EmployeeDetailedDto {
@IsString() @IsNotEmpty() first_name: string; @IsString() @IsNotEmpty() first_name: string;
@ -15,6 +16,7 @@ export class EmployeeDetailedDto {
@IsInt() daily_expected_hours: number; @IsInt() daily_expected_hours: number;
@IsDateString() @IsOptional() last_work_day?: string | null; @IsDateString() @IsOptional() last_work_day?: string | null;
@IsString() @IsOptional() residence?: string; @IsString() @IsOptional() residence?: string;
@IsOptional() @Type(() => PaidTimeOffDto) paid_time_off?: Partial<PaidTimeOffDto> | null;
@IsInt() @IsPositive() @Type(() => Number) external_payroll_id: number; @IsInt() @IsPositive() @Type(() => Number) external_payroll_id: number;
@IsArray() @IsString({ each: true }) user_module_access: string[]; @IsArray() @IsString({ each: true }) user_module_access: string[];
@IsInt() @IsOptional() preset_id?: number; @IsInt() @IsOptional() preset_id?: number;

View File

@ -25,6 +25,7 @@ export class EmployeesGetService {
first_name: true, first_name: true,
last_name: true, last_name: true,
email: true, email: true,
phone_number: true,
}, },
}, },
supervisor: { supervisor: {
@ -51,6 +52,7 @@ export class EmployeesGetService {
first_name: r.user.first_name, first_name: r.user.first_name,
last_name: r.user.last_name, last_name: r.user.last_name,
email: r.user.email, email: r.user.email,
phone_number: r.user.phone_number,
company_name: toStringFromCompanyCode(r.company_code), company_name: toStringFromCompanyCode(r.company_code),
job_title: r.job_title ?? '', job_title: r.job_title ?? '',
daily_expected_hours: r.daily_expected_hours, daily_expected_hours: r.daily_expected_hours,
@ -85,6 +87,7 @@ export class EmployeesGetService {
company_code: true, company_code: true,
job_title: true, job_title: true,
external_payroll_id: true, external_payroll_id: true,
paid_time_off: true,
is_supervisor: true, is_supervisor: true,
schedule_preset_id: true, schedule_preset_id: true,
daily_expected_hours: true, daily_expected_hours: true,
@ -114,6 +117,11 @@ export class EmployeesGetService {
daily_expected_hours: existing_profile.daily_expected_hours, daily_expected_hours: existing_profile.daily_expected_hours,
job_title: existing_profile.job_title ?? '', job_title: existing_profile.job_title ?? '',
external_payroll_id: existing_profile.external_payroll_id, external_payroll_id: existing_profile.external_payroll_id,
paid_time_off: {
vacation_hours: existing_profile.paid_time_off?.vacation_hours.toNumber() ?? 0,
banked_hours: existing_profile.paid_time_off?.banked_hours.toNumber() ?? 0,
last_updated: existing_profile.paid_time_off?.last_updated.toISOString().slice(0, 10) ?? '',
},
is_supervisor: existing_profile.is_supervisor, is_supervisor: existing_profile.is_supervisor,
phone_number: existing_profile.user.phone_number, phone_number: existing_profile.user.phone_number,
residence: existing_profile.user.phone_number, residence: existing_profile.user.phone_number,
@ -165,6 +173,7 @@ export class EmployeesGetService {
first_work_day: true, first_work_day: true,
last_work_day: true, last_work_day: true,
external_payroll_id: true, external_payroll_id: true,
paid_time_off: true,
is_supervisor: true, is_supervisor: true,
daily_expected_hours: true, daily_expected_hours: true,
schedule_preset_id: true, schedule_preset_id: true,
@ -197,6 +206,14 @@ export class EmployeesGetService {
is_supervisor: employee.is_supervisor ?? false, is_supervisor: employee.is_supervisor ?? false,
job_title: employee.job_title ?? '', job_title: employee.job_title ?? '',
external_payroll_id: employee.external_payroll_id, external_payroll_id: employee.external_payroll_id,
paid_time_off: {
id: employee.paid_time_off?.id ?? -1,
employee_id: employee.paid_time_off?.employee_id ?? -1,
sick_hours: employee.paid_time_off?.sick_hours.toNumber() ?? 0,
vacation_hours: employee.paid_time_off?.vacation_hours.toNumber() ?? 0,
banked_hours: employee.paid_time_off?.banked_hours.toNumber() ?? 0,
last_updated: employee.paid_time_off?.last_updated.toISOString().slice(0, 10) ?? '',
},
employee_full_name: `${employee.user.first_name} ${employee.user.last_name}`, employee_full_name: `${employee.user.first_name} ${employee.user.last_name}`,
first_work_day: toStringFromDate(employee.first_work_day), first_work_day: toStringFromDate(employee.first_work_day),
last_work_day: employee.last_work_day ? toStringFromDate(employee.last_work_day) : undefined, last_work_day: employee.last_work_day ? toStringFromDate(employee.last_work_day) : undefined,

View File

@ -0,0 +1,11 @@
import { Type } from "class-transformer";
import { IsDateString, IsDecimal, IsInt, IsNotEmpty, IsNumber, IsOptional } from "class-validator";
export class PaidTimeOffDto {
@IsInt() @IsNotEmpty() id: number;
@IsInt() @IsNotEmpty() employee_id: number;
@IsOptional() @Type(() => Number) vacation_hours?: number;
@IsOptional() @Type(() => Number) sick_hours?: number;
@IsOptional() @Type(() => Number) banked_hours?: number;
@IsDateString() @IsOptional() last_updated: string;
}