import { IsString, IsNotEmpty, IsOptional, IsNumber, IsBoolean, IsEnum, IsUUID } from 'class-validator';
import { Type } from 'class-transformer';
import { TransactionType, ReconciliationStatus } from '@prisma/client';

export class CreateBankAccountDto {
  @IsUUID()
  complexId: string;

  @IsString()
  @IsNotEmpty()
  bankName: string;

  @IsString()
  @IsNotEmpty()
  accountName: string;

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

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

  @IsNumber()
  @Type(() => Number)
  @IsOptional()
  initialBalance?: number;

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

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

export class UpdateBankAccountDto {
  @IsString()
  @IsOptional()
  bankName?: string;

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

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

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

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

export class CreateBankTransactionDto {
  @IsUUID()
  bankAccountId: string;

  @IsString()
  @IsNotEmpty()
  date: string; // ISO date

  @IsString()
  @IsNotEmpty()
  label: string;

  @IsNumber()
  @Type(() => Number)
  amount: number;

  @IsEnum(TransactionType)
  type: TransactionType;

  @IsString()
  @IsOptional()
  notes?: string;
}

export class UpdateBankTransactionStatusDto {
  @IsEnum(ReconciliationStatus)
  status: ReconciliationStatus;
}
