import { ApiPropertyOptional } from '@nestjs/swagger';
import { Type } from 'class-transformer';
import {
  IsArray,
  IsBoolean,
  IsOptional,
  IsString,
  ValidateNested,
} from 'class-validator';
import { DateRangeDto } from 'src/utils/datetime/dateRangeDto';
import { PaginationDto } from 'src/config/pagination/paginationDto';

/**
 * DTO used for searching Bonus Received records with multiple filters.
 *
 * Extends PaginationDto to include standard pagination options.
 * Can filter by association type, visa service country, bank account,
 * creator/updater, associate, payment mode, and date ranges.
 */
export class SearchBonusReceivedDto extends PaginationDto {
  /**
   * Optional search keyword for filtering by title or description.
   */
  @ApiPropertyOptional()
  @IsOptional()
  @IsString()
  search_title?: string;

  /**
   * Optional filter by association type (e.g., sub-agent, institute, etc.).
   */
  @ApiPropertyOptional()
  @IsOptional()
  @IsString()
  association_type?: string;

  /**
   * Optional array of visa service country IDs to filter results.
   */
  @ApiPropertyOptional()
  @IsOptional()
  @IsArray()
  visa_service_country_id?: string[];

  /**
   * Optional array of bank account IDs to filter results.
   */
  @ApiPropertyOptional()
  @IsOptional()
  @IsArray()
  bank_account_id?: string[];

  /**
   * Optional array of creator user IDs for filtering records.
   */
  @ApiPropertyOptional()
  @IsOptional()
  @IsArray()
  created_by?: string[];

  /**
   * Optional array of updater user IDs for filtering records.
   */
  @ApiPropertyOptional()
  @IsOptional()
  @IsArray()
  updated_by?: string[];

  /**
   * Optional array of associate IDs for filtering records.
   */
  @ApiPropertyOptional()
  @IsOptional()
  @IsArray()
  associate_id?: string[];

  /**
   * Optional array of payment mode IDs for filtering records.
   */
  @ApiPropertyOptional()
  @IsOptional()
  @IsArray()
  payment_mode_id?: string[];

  /**
   * Optional flag to indicate whether results should be exported as CSV.
   * Defaults to false.
   */
  @ApiPropertyOptional()
  @IsOptional()
  @IsBoolean()
  is_csv?: boolean = false;

  /**
   * Optional date range filter for record creation.
   */
  @ApiPropertyOptional({ type: DateRangeDto })
  @IsOptional()
  @ValidateNested()
  @Type(() => DateRangeDto)
  created_on?: DateRangeDto;

  /**
   * Optional date range filter for record updates.
   */
  @ApiPropertyOptional({ type: DateRangeDto })
  @IsOptional()
  @ValidateNested()
  @Type(() => DateRangeDto)
  updated_on?: DateRangeDto;
}
