import { ApiProperty } from '@nestjs/swagger';
import { IsNotEmpty, IsNumber, IsOptional } from 'class-validator';

/**
 * DTO for searching commission instances based on multiple optional filters.
 *
 * This DTO is used to fetch commission instance records filtered by
 * institute, visa service country, associate, client country, intake, and association type.
 * All fields are numbers, representing IDs from related tables/entities.
 */
export class SearchCommissionInstancesDto {
  /**
   * ID of the visa service country.
   *
   * Optional filter to narrow results to a specific visa service country.
   *
   * Example:
   * ```json
   * {
   *   "visa_service_country_id": 5
   * }
   * ```
   */
  @ApiProperty({
    description: 'ID of the visa service country',
    required: false,
  })
  @IsNumber({}, { message: 'visa_service_country_id must be a number' })
  @IsOptional()
  visa_service_country_id: number;

  /**
   * ID of the associate.
   *
   * Optional filter to get commission instances linked to a specific associate.
   *
   * Example:
   * ```json
   * {
   *   "associate_id": 9
   * }
   * ```
   */
  @ApiProperty({ description: 'ID of the associate', required: false })
  @IsNumber({}, { message: 'associate_id must be a number' })
  @IsOptional()
  associate_id?: number;

  /**
   * ID of the institute.
   *
   * Mandatory field. Used to fetch commission instances belonging to a particular institute.
   *
   * Example:
   * ```json
   * {
   *   "institute_id": 459
   * }
   * ```
   */
  @ApiProperty({ description: 'ID of the institute', required: true })
  @IsNumber({}, { message: 'institute_id must be a number' })
  @IsNotEmpty({ message: 'institute_id is required' })
  institute_id: number;

  /**
   * ID of the client's home country.
   *
   * Optional filter to limit results to commissions related to a particular client country.
   *
   * Example:
   * ```json
   * {
   *   "client_from_country_id": 80
   * }
   * ```
   */
  @ApiProperty({
    description: "ID of the client's home country",
    required: false,
  })
  @IsNumber({}, { message: 'client_from_country_id must be a number' })
  @IsOptional()
  client_from_country_id: number;

  /**
   * ID of the intake/session.
   *
   * Optional filter to get commission instances for a specific intake.
   *
   * Example:
   * ```json
   * {
   *   "intake_id": 95504
   * }
   * ```
   */
  @ApiProperty({ description: 'ID of the intake/session', required: false })
  @IsNumber({}, { message: 'intake_id must be a number' })
  @IsOptional()
  intake_id: number;

  /**
   * Type of association (numeric value corresponding to the association type).
   *
   * Optional filter to restrict results to a certain association type.
   *
   * Example:
   * ```json
   * {
   *   "association_type": 1
   * }
   * ```
   */
  @ApiProperty({ description: 'Association type ID', required: false })
  @IsNumber({}, { message: 'association_type must be a number' })
  @IsOptional()
  association_type: number;
}
