/**
 * Contract DTOs
 * @module HR
 */

import {
  IsString,
  IsOptional,
  IsNumber,
  IsUUID,
  MaxLength,
  IsDateString,
  IsEnum,
  Min,
  IsInt,
} from 'class-validator';
import { ContractType, ContractStatus, WageType } from '../entities/contract.entity';

export class CreateContractDto {
  @IsUUID()
  companyId: string;

  @IsUUID()
  employeeId: string;

  @IsString()
  @MaxLength(255)
  name: string;

  @IsOptional()
  @IsString()
  @MaxLength(50)
  reference?: string;

  @IsOptional()
  @IsEnum(['permanent', 'temporary', 'contractor', 'internship', 'part_time'])
  contractType?: ContractType;

  @IsOptional()
  @IsEnum(['draft', 'active', 'expired', 'terminated', 'cancelled'])
  status?: ContractStatus;

  @IsDateString()
  dateStart: string;

  @IsOptional()
  @IsDateString()
  dateEnd?: string;

  @IsOptional()
  @IsUUID()
  jobPositionId?: string;

  @IsOptional()
  @IsUUID()
  departmentId?: string;

  @IsNumber()
  @Min(0)
  wage: number;

  @IsOptional()
  @IsEnum(['hourly', 'daily', 'weekly', 'biweekly', 'monthly', 'annual'])
  wageType?: WageType;

  @IsOptional()
  @IsString()
  @MaxLength(3)
  currency?: string;

  @IsOptional()
  @IsNumber()
  @Min(0)
  hoursPerWeek?: number;

  @IsOptional()
  @IsString()
  @MaxLength(50)
  scheduleType?: string;

  @IsOptional()
  @IsInt()
  @Min(0)
  trialPeriodMonths?: number;

  @IsOptional()
  @IsDateString()
  trialDateEnd?: string;

  @IsOptional()
  @IsString()
  notes?: string;

  @IsOptional()
  @IsString()
  documentUrl?: string;
}

export class UpdateContractDto {
  @IsOptional()
  @IsString()
  @MaxLength(255)
  name?: string;

  @IsOptional()
  @IsString()
  @MaxLength(50)
  reference?: string;

  @IsOptional()
  @IsEnum(['permanent', 'temporary', 'contractor', 'internship', 'part_time'])
  contractType?: ContractType;

  @IsOptional()
  @IsEnum(['draft', 'active', 'expired', 'terminated', 'cancelled'])
  status?: ContractStatus;

  @IsOptional()
  @IsDateString()
  dateStart?: string;

  @IsOptional()
  @IsDateString()
  dateEnd?: string;

  @IsOptional()
  @IsUUID()
  jobPositionId?: string;

  @IsOptional()
  @IsUUID()
  departmentId?: string;

  @IsOptional()
  @IsNumber()
  @Min(0)
  wage?: number;

  @IsOptional()
  @IsEnum(['hourly', 'daily', 'weekly', 'biweekly', 'monthly', 'annual'])
  wageType?: WageType;

  @IsOptional()
  @IsString()
  @MaxLength(3)
  currency?: string;

  @IsOptional()
  @IsNumber()
  @Min(0)
  hoursPerWeek?: number;

  @IsOptional()
  @IsString()
  @MaxLength(50)
  scheduleType?: string;

  @IsOptional()
  @IsInt()
  @Min(0)
  trialPeriodMonths?: number;

  @IsOptional()
  @IsDateString()
  trialDateEnd?: string;

  @IsOptional()
  @IsString()
  notes?: string;

  @IsOptional()
  @IsString()
  documentUrl?: string;
}

export class TerminateContractDto {
  @IsString()
  terminationReason: string;
}
