import { IsArray, IsBoolean, IsDateString, IsEmail, IsInt, IsNotEmpty, IsOptional, IsPositive, IsString } from 'class-validator'; import { Type } from 'class-transformer'; import { PaidTimeOffDto } from 'src/time-and-attendance/paid-time-off/paid-time-off.dto'; import { Prisma } from 'prisma/postgres/generated/prisma/client/postgres/client'; import { Contract } from 'src/identity-and-account/contract/contract.dto'; export class EmployeeDetailedDto { @IsString() @IsNotEmpty() first_name: string; @IsString() @IsNotEmpty() last_name: string; @IsString() @IsOptional() employee_full_name: string; @IsString() @IsOptional() supervisor_full_name: string; @IsOptional() @IsBoolean() is_supervisor: boolean; @IsString() company_name: string; @IsString() @IsOptional() job_title: string; @IsEmail() @IsOptional() email: string; @IsString() phone_number: string; @IsDateString() first_work_day: string; @IsDateString() @IsOptional() last_work_day?: string | null; @IsString() @IsOptional() residence?: string; @IsInt() @Type(() => Contract) contract: Partial; @IsOptional() @Type(() => PaidTimeOffDto) paid_time_off?: Partial; @IsInt() @IsPositive() @Type(() => Number) external_payroll_id: number; @IsArray() @IsString({ each: true }) user_module_access: string[]; @IsInt() @IsOptional() preset_id?: number; } export class EmployeeDetailedUpsertDto { @IsString() @IsNotEmpty() first_name: string; @IsString() @IsNotEmpty() last_name: string; @IsString() @IsOptional() employee_full_name: string; @IsString() @IsOptional() supervisor_full_name: string; @IsOptional() @IsBoolean() is_supervisor: boolean; @IsString() company_name: string; @IsString() @IsOptional() job_title: string; @IsEmail() @IsOptional() email: string; @IsString() phone_number: string; @IsDateString() first_work_day: string; @IsDateString() @IsOptional() last_work_day?: string | null; @IsString() @IsOptional() residence?: string; @IsInt() @Type(() => Contract) contract: Partial; @IsOptional() @Type(() => PaidTimeOffDto) paid_time_off?: PaidTimeOffDto; @IsInt() @IsPositive() @Type(() => Number) external_payroll_id: number; @IsArray() @IsString({ each: true }) user_module_access: string[]; @IsInt() @IsOptional() preset_id?: number; } export type EmployeeWithDetails = Prisma.EmployeesGetPayload<{ select: { user: { select: { first_name: true, last_name: true, email: true, phone_number: true, residence: true, user_module_access: { select: { dashboard: true, employee_list: true, employee_management: true, personal_profile: true, timesheets: true, timesheets_approval: true, ticket: true, ticket_management: true, chatbot: true, } } } }, supervisor: { select: { user: { select: { first_name: true, last_name: true } } } }, job_title: true, company_code: true, first_work_day: true, last_work_day: true, external_payroll_id: true, paid_time_off: { select: { id: true, employee_id: true, sick_hours: true, vacation_hours: true, banked_hours: true, last_updated: true, }, }, is_supervisor: true, contracts: { select: { daily_expected_hours: true, applicable_overtime: true, weekend_on_call_allocation: true, on_call_allocation: true, phone_allocation: true, }, }, schedule_preset_id: true, schedule_preset: { select: { id: true } } } }>;