import {
  IsString,
  IsOptional,
  IsEnum,
  IsDateString,
  IsNumber,
  MaxLength,
  Min,
} from 'class-validator';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';

export enum ContractStatus {
  DRAFT = 'DRAFT',
  ACTIVE = 'ACTIVE',
  EXPIRED = 'EXPIRED',
  CANCELLED = 'CANCELLED',
}

export class CreateContractDto {
  @ApiProperty({ maxLength: 255, description: 'Vertragsbezeichnung' })
  @IsString()
  @MaxLength(255)
  title!: string;

  @ApiPropertyOptional({
    enum: ContractStatus,
    default: ContractStatus.DRAFT,
    description: 'Vertragsstatus',
  })
  @IsOptional()
  @IsEnum(ContractStatus)
  status?: ContractStatus;

  @ApiPropertyOptional({ format: 'date-time', description: 'Vertragsbeginn' })
  @IsOptional()
  @IsDateString()
  startDate?: string;

  @ApiPropertyOptional({ format: 'date-time', description: 'Vertragsende' })
  @IsOptional()
  @IsDateString()
  endDate?: string;

  @ApiPropertyOptional({ description: 'Vertragswert', minimum: 0 })
  @IsOptional()
  @IsNumber({ maxDecimalPlaces: 2 })
  @Min(0)
  value?: number;

  @ApiPropertyOptional({
    default: 'EUR',
    maxLength: 3,
    description: 'Waehrung (ISO 4217)',
  })
  @IsOptional()
  @IsString()
  @MaxLength(3)
  currency?: string;

  @ApiPropertyOptional({ description: 'Notizen zum Vertrag' })
  @IsOptional()
  @IsString()
  notes?: string;
}
