import {
  IsBoolean,
  IsEmail,
  IsEnum,
  IsInt,
  IsNumber,
  IsOptional,
  IsString,
} from "class-validator";
import { Currency } from "@jorgecuadros/database";

// Each child DTO covers create; updates reuse the same shape with all fields
// optional via the corresponding Update class. Route supplies the policyId.

export class InstallmentDto {
  @IsInt() sequence!: number;
  @IsOptional() @IsNumber() amount?: number;
  @IsOptional() @IsEnum(Currency) currency?: Currency;
  @IsOptional() @IsString() dueDate?: string;
  @IsOptional() @IsString() paidDate?: string;
  @IsOptional() @IsString() checkNumber?: string;
  @IsOptional() @IsBoolean() isCash?: boolean;
}
export class UpdateInstallmentDto {
  @IsOptional() @IsInt() sequence?: number;
  @IsOptional() @IsNumber() amount?: number;
  @IsOptional() @IsEnum(Currency) currency?: Currency;
  @IsOptional() @IsString() dueDate?: string;
  @IsOptional() @IsString() paidDate?: string;
  @IsOptional() @IsString() checkNumber?: string;
  @IsOptional() @IsBoolean() isCash?: boolean;
}

export class VehicleDto {
  @IsOptional() @IsString() make?: string;
  @IsOptional() @IsString() model?: string;
  @IsOptional() @IsString() modelYear?: string;
  @IsOptional() @IsString() bodyType?: string;
  @IsOptional() @IsString() engineNumber?: string;
  @IsOptional() @IsString() licensePlate?: string;
  @IsOptional() @IsString() vinNumber?: string;
  @IsOptional() @IsString() stateCode?: string;
  @IsOptional() @IsString() notes?: string;
}
export class UpdateVehicleDto extends VehicleDto {}

export class DriverDto {
  @IsOptional() @IsString() fullName?: string;
  @IsOptional() @IsString() birthDate?: string;
  @IsOptional() @IsString() sex?: string;
  @IsOptional() @IsString() occupation?: string;
  @IsOptional() @IsString() licenseNumber?: string;
  @IsOptional() @IsString() licenseState?: string;
}
export class UpdateDriverDto extends DriverDto {}

export class BeneficiaryDto {
  @IsOptional() @IsString() name?: string;
  @IsOptional() @IsString() address?: string;
  @IsOptional() @IsString() phone?: string;
  @IsOptional() @IsEmail() email?: string;
}
export class UpdateBeneficiaryDto extends BeneficiaryDto {}

export class ClaimDto {
  @IsOptional() @IsString() claimType?: string;
  @IsOptional() @IsString() incidentDate?: string;
  @IsOptional() @IsString() reportedDate?: string;
  @IsOptional() @IsString() description?: string;
  @IsOptional() @IsString() adjusterId?: string;
  @IsOptional() @IsNumber() claimedAmount?: number;
  @IsOptional() @IsNumber() settledAmount?: number;
  @IsOptional() @IsString() settlementDate?: string;
  @IsOptional() @IsString() checkNumber?: string;
  @IsOptional() @IsBoolean() resolved?: boolean;
  @IsOptional() @IsString() resolutionNotes?: string;
}
export class UpdateClaimDto extends ClaimDto {}
