/**
 * LeaveType DTOs
 * @module HR
 */

import {
  IsString,
  IsOptional,
  IsBoolean,
  IsNumber,
  IsUUID,
  MaxLength,
  IsEnum,
  Min,
  Max,
  IsInt,
} from 'class-validator';
import { LeaveTypeCategory, AllocationType } from '../entities/leave-type.entity';

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

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

  @IsString()
  @MaxLength(50)
  code: string;

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

  @IsOptional()
  @IsString()
  @MaxLength(7)
  color?: string;

  @IsOptional()
  @IsEnum(['vacation', 'sick', 'personal', 'maternity', 'paternity', 'bereavement', 'unpaid', 'other'])
  leaveCategory?: LeaveTypeCategory;

  @IsOptional()
  @IsEnum(['fixed', 'accrual', 'unlimited'])
  allocationType?: AllocationType;

  @IsOptional()
  @IsBoolean()
  requiresApproval?: boolean;

  @IsOptional()
  @IsBoolean()
  requiresDocument?: boolean;

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

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

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

  @IsOptional()
  @IsBoolean()
  isPaid?: boolean;

  @IsOptional()
  @IsNumber()
  @Min(0)
  @Max(100)
  payPercentage?: number;

  @IsOptional()
  @IsBoolean()
  isActive?: boolean;
}

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

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

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

  @IsOptional()
  @IsString()
  @MaxLength(7)
  color?: string;

  @IsOptional()
  @IsEnum(['vacation', 'sick', 'personal', 'maternity', 'paternity', 'bereavement', 'unpaid', 'other'])
  leaveCategory?: LeaveTypeCategory;

  @IsOptional()
  @IsEnum(['fixed', 'accrual', 'unlimited'])
  allocationType?: AllocationType;

  @IsOptional()
  @IsBoolean()
  requiresApproval?: boolean;

  @IsOptional()
  @IsBoolean()
  requiresDocument?: boolean;

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

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

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

  @IsOptional()
  @IsBoolean()
  isPaid?: boolean;

  @IsOptional()
  @IsNumber()
  @Min(0)
  @Max(100)
  payPercentage?: number;

  @IsOptional()
  @IsBoolean()
  isActive?: boolean;
}
