import { ApiPropertyOptional } from '@nestjs/swagger';
import { IsInt, IsNumber, IsString, Length, Max, Min, ValidateIf } from 'class-validator';

/** PATCH /tes/config: las tres columnas son NOT NULL, así que ausente pasa pero `null` da 400. Solo estos tres campos; `empresa_id` o `id` reciben 400 del ValidationPipe global. */
export class UpdateTesConfigDto {
  @ApiPropertyOptional({ example: 5000000, description: 'Monto desde el cual un pago pide aprobación (0 = sin umbral)' })
  @ValidateIf((_, v) => v !== undefined)
  @IsNumber({ maxDecimalPlaces: 2 })
  @Min(0)
  monto_umbral_aprobacion?: number;

  @ApiPropertyOptional({ example: 7, description: 'Días de anticipación para avisar el vencimiento de cheques (1 a 90)' })
  @ValidateIf((_, v) => v !== undefined)
  @IsInt()
  @Min(1)
  @Max(90)
  dias_alerta_cheques?: number;

  @ApiPropertyOptional({ example: 'PYG', description: 'Moneda base de los reportes; tiene que estar activa en la empresa' })
  @ValidateIf((_, v) => v !== undefined)
  @IsString()
  @Length(3, 3)
  moneda_base_reportes?: string;
}
