import { IsString, IsNotEmpty, IsNumber, IsOptional, IsBoolean, IsDateString, IsIn, Min } from 'class-validator'

const TYPES = ['receipt','disbursement','transfer_out','interest','fee_draw','refund','adjustment']

export class CreateTrustTransactionDto {
  @IsString() @IsNotEmpty()
  clientFolderId: string

  @IsOptional() @IsString()
  matterId?: string

  @IsDateString()
  txDate: string

  @IsIn(TYPES)
  type: string

  @IsNumber() @Min(0.01)
  amount: number

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

  @IsString() @IsNotEmpty()
  description: string

  @IsOptional() @IsString()
  reference?: string

  @IsOptional() @IsString()
  invoiceId?: string

  @IsString() @IsNotEmpty()
  createdBy: string
}

export class ReconcileDto {
  @IsNumber() @Min(0)
  bankBalance: number

  @IsString() @IsNotEmpty()
  reconciledBy: string

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

export class MarkReconciledDto {
  @IsString({ each: true })
  txIds: string[]

  @IsOptional() @IsString()
  bankStatementRef?: string
}
