import {
  IsDateString,
  IsNumber,
  IsOptional,
  IsString,
  Min,
  MaxLength,
} from 'class-validator';
import { Type } from 'class-transformer';

/**
 * Record a physical cash-at-service collection event.
 *
 * `collected_at` is user-entered (when the guest actually paid), not
 * `NOW()` — a driver may log the row a few hours later. `collected_by`
 * is resolved from CLS (the DMC user who typed the confirmation), not
 * from the payload.
 *
 * `difference_reason` is REQUIRED when actual_amount ≠
 * collection.expected_amount. Enforced at service layer (needs the
 * expected amount from the parent row to compare).
 */
export class ConfirmCollectionDto {
  @Type(() => Number)
  @IsNumber({ maxDecimalPlaces: 2 })
  @Min(0)
  actual_amount: number;

  @IsDateString()
  collected_at: string;

  @IsOptional()
  @IsString()
  @MaxLength(500)
  difference_reason?: string;

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