import {
  IsNumber,
  IsOptional,
  IsString,
  IsInt,
  Min,
  Max,
  IsDateString,
} from 'class-validator';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { Type } from 'class-transformer';

export class WithdrawDto {
  @ApiProperty({ minimum: 0.01, description: 'Withdrawal amount' })
  @IsNumber()
  @Min(0.01)
  amount: number;
}

export class ListTransactionsQueryDto {
  @ApiPropertyOptional({ default: 1 })
  @IsOptional()
  @Type(() => Number)
  @IsInt()
  @Min(1)
  page?: number = 1;

  @ApiPropertyOptional({ default: 20 })
  @IsOptional()
  @Type(() => Number)
  @IsInt()
  @Min(1)
  @Max(100)
  limit?: number = 20;

  @ApiPropertyOptional({ enum: ['sale', 'redemption', 'withdrawal', 'fee'] })
  @IsOptional()
  @IsString()
  type?: string;
}

export class ReconciliationQueryDto {
  @ApiPropertyOptional({ description: 'Period start date (ISO 8601)' })
  @IsOptional()
  @IsDateString()
  startDate?: string;

  @ApiPropertyOptional({ description: 'Period end date (ISO 8601)' })
  @IsOptional()
  @IsDateString()
  endDate?: string;

  @ApiPropertyOptional({ description: 'Period shorthand: month, quarter, year' })
  @IsOptional()
  @IsString()
  period?: string;
}
