import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'; import { Transform } from 'class-transformer'; import { IsDateString, IsIn, IsNumber, IsOptional, IsString, IsUUID, MaxLength, Min } from 'class-validator'; import { RATE_TYPES, RATE_UNITS } from '../entities/rate.entity'; const TRADE_DIRECTIONS = ['IMPORT', 'EXPORT', 'BOTH'] as const; const CURRENCIES = ['ETB', 'USD'] as const; export class CreateRateDto { @ApiProperty({ enum: RATE_TYPES, description: 'Rate type identifier' }) @IsIn([...RATE_TYPES]) rateType!: string; @ApiPropertyOptional({ description: 'FK to container_types.id — null for non-container rates' }) @IsOptional() @IsUUID() containerTypeId?: string; @ApiPropertyOptional({ enum: TRADE_DIRECTIONS, description: 'Trade direction. Null = direction-agnostic' }) @IsOptional() @IsIn([...TRADE_DIRECTIONS]) tradeDirection?: string; @ApiProperty({ enum: CURRENCIES }) @IsIn([...CURRENCIES]) currency!: string; @ApiProperty({ description: 'Numeric rate value', minimum: 0 }) @IsNumber() @Min(0) @Transform(({ value }) => Number(value)) rateValue!: number; @ApiProperty({ enum: RATE_UNITS, description: 'Unit basis for the rate' }) @IsIn([...RATE_UNITS]) rateUnit!: string; @ApiProperty({ description: 'ID of the staff member (Director) proposing this rate' }) @IsUUID() proposedByStaffId!: string; @ApiProperty({ description: 'Date from which this rate is effective (ISO date)', example: '2025-01-01' }) @IsDateString() effectiveFrom!: string; @ApiPropertyOptional({ description: 'Date when this rate expires. Null = currently active', example: '2025-12-31' }) @IsOptional() @IsDateString() effectiveTo?: string; } export class ApproveRateDto { @ApiProperty({ description: 'ID of the CEO approving this rate' }) @IsUUID() approvedByCeoId!: string; } export class SubmitRateForApprovalDto { @ApiPropertyOptional({ description: 'Optional note for the approval request', maxLength: 500 }) @IsOptional() @IsString() @MaxLength(500) note?: string; }