// Import core NestJS module decorator
import { Module } from '@nestjs/common';

// Import TypeORM integration for database operations
import { TypeOrmModule } from '@nestjs/typeorm';

// Import cache module for caching capabilities
import { CacheModule } from '@nestjs/cache-manager';

// Import controller and service
import { VisaBonusReceivedController } from './visa-bonus-received.controller';
import { VisaBonusReceivedService } from './visa-bonus-received.service';

// Import multiple entity definitions (6 different entities)
import { VisaServiceMasterEntity } from 'src/entities/VisaServiceMaster.entity';
import { CollegeEntity } from 'src/entities/College.entity';
import { MasteragentEntity } from 'src/entities/Masteragent.entity';
import { FileService } from 'src/services/file.service';
import { VcmCommissionBonusReceivedEntity } from 'src/entities/VcmCommissionBonusReceived.entity';
import { CompanyBankAccountEntity } from 'src/entities/CompanyBankAccount.entity';
import { PaymentModeMasterEntity } from 'src/entities/PaymentModeMaster.entity';

/**
 * VisaBonusReceivedModule - Feature module for visa bonus receipt management
 *
 * This module encapsulates all components related to tracking bonuses received
 * from partners/institutes for visa/immigration cases. It represents a financial
 * tracking system within an education/visa consultancy business.
 *
 * Business Domain: Visa Commission & Bonus Management
 * - Tracks bonuses received from educational institutes and master agents
 * - Manages financial transactions for visa case commissions
 * - Handles documentation and proof for bonus payments
 * - Supports multiple association types (institutes vs master agents)
 *
 * Module Characteristics:
 * - 6 entity integrations covering different aspects of bonus management
 * - File upload support for transaction documentation
 * - Caching for performance optimization
 * - Multi-association type support (institutes and master agents)
 */
@Module({
  /**
   * controllers - Array of controllers that handle HTTP requests
   *
   * VisaBonusReceivedController: Provides comprehensive bonus receipt management
   * - 22+ endpoints for CRUD operations and filtering
   * - File attachment management for transaction proof
   * - Multi-type filtering based on association relationships
   * - Reference data endpoints for dropdowns
   */
  controllers: [VisaBonusReceivedController],

  /**
   * providers - Injectable services available within this module
   *
   * 1. VisaBonusReceivedService: Core business logic for bonus receipt operations
   *    - Complex bonus receipt tracking and calculations
   *    - Multi-entity joins for association type filtering
   *    - Financial transaction validation and processing
   *    - Integration with 6 different entity repositories
   *
   * 2. FileService: Shared service for file operations
   *    - Handles file uploads, storage, and retrieval
   *    - Manages transaction documentation (screenshots, receipts)
   *    - Provides file validation and security checks
   *    - Used for audit trail and compliance documentation
   */
  providers: [VisaBonusReceivedService, FileService],

  /**
   * imports - External modules and dependencies required by this module
   *
   * 1. CacheModule.register(): Configures the caching system
   *    - Provides in-memory caching for frequently accessed data
   *    - Important for reference data (countries, payment modes, banks)
   *    - Reduces database load for filter dropdown population
   *
   * 2. TypeOrmModule.forFeature([...]): Registers 6 entities with TypeORM
   *    - Creates repositories for each entity that can be injected into services
   *    - Enables complex queries across multiple related entities
   *    - Supports transaction management for financial operations
   */
  imports: [
    CacheModule.register(), // Default cache configuration

    /**
     * TypeOrmModule.forFeature with 6 related entities:
     * This represents a comprehensive bonus receipt tracking system:
     */
    TypeOrmModule.forFeature([
      /**
       * 1. VisaServiceMasterEntity (Service Reference)
       *    - Visa service types and products
       *    - Examples: Student Visa, Tourist Visa, Work Visa
       *    - Defines which services are eligible for bonuses
       *    - Used for service-specific bonus calculations
       */
      VisaServiceMasterEntity,

      /**
       * 2. CollegeEntity (Educational Institute Reference)
       *    - Educational institutions/colleges/universities
       *    - Institute details, rankings, commission agreements
       *    - Represents one type of bonus payer (institutes)
       *    - Institute-specific bonus rates and terms
       */
      CollegeEntity,

      /**
       * 3. MasteragentEntity (Master Agent Reference)
       *    - Master/primary agents or partners
       *    - Agent details, contract terms, status
       *    - Represents another type of bonus payer (agents)
       *    - Agent-specific commission structures
       */
      MasteragentEntity,

      /**
       * 4. VcmCommissionBonusReceivedEntity (Core Transaction Entity)
       *    - Main bonus receipt transaction records
       *    - Stores bonus amounts, dates, status, references
       *    - Contains foreign keys to payer (institute or agent)
       *    - Likely includes: bonus_id, amount, received_date, status
       */
      VcmCommissionBonusReceivedEntity,

      /**
       * 5. CompanyBankAccountEntity (Financial Account)
       *    - Company's bank accounts where bonuses are received
       *    - Source/destination accounts for bonus transactions
       *    - Bank details, account numbers, verification status
       *    - Used for financial reconciliation and reporting
       */
      CompanyBankAccountEntity,

      /**
       * 6. PaymentModeMasterEntity (Payment Method Reference)
       *    - Reference table for payment methods
       *    - Examples: Bank Transfer, Cash, Check, Online Payment
       *    - Used for transaction categorization and reporting
       *    - May include processing fees or timing considerations
       */
      PaymentModeMasterEntity,
    ]),
  ],
})
export class VisaBonusReceivedModule {}
