import { IsEnum, IsNumber, IsOptional, IsString, MaxLength, Min } from 'class-validator';
import { SettlementPaymentMode } from '../../../entities/settlement-payment.entity';

/**
 * Settle Dialog payload — partial OR full. The service enforces
 * `paid_amount ≤ outstanding` (settlement.amount − settlement.amount_settled),
 * so the FE can either default `paid_amount` to outstanding (one-click
 * "Pay full") or accept a smaller number for a partial.
 */
export class RecordPaymentDto {
  @IsNumber()
  @Min(0.01)
  paid_amount: number;

  // ISO date (YYYY-MM-DD). Lets ops back-date a payment that landed
  // yesterday but is being logged today. Server-side parsing happens
  // in the DB driver — we keep the type as string here.
  @IsString()
  @MaxLength(20)
  paid_date: string;

  @IsEnum(SettlementPaymentMode)
  mode: SettlementPaymentMode;

  @IsString()
  @IsOptional()
  @MaxLength(100)
  ref_no?: string;

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