import { Global, Module } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { TypeOrmModule } from '@nestjs/typeorm';
import { CONNECTION_NAME } from 'src/core/strings/constants/base.constants';
import {
  SalesPriceFormulaDataService,
  TransactionSettingDataService,
} from './data/services/sales-price-formula-data.service';
import { SalesPriceFormulaReadService } from './data/services/sales-price-formula-read.service';
import { SalesPriceFormulaReadController } from './infrastructure/sales-price-formula-read.controller';
import { SalesPriceFormulaReadOrchestrator } from './domain/usecases/sales-price-formula-read.orchestrator';
import { SalesPriceFormulaDataController } from './infrastructure/sales-price-formula-data.controller';
import { SalesPriceFormulaDataOrchestrator } from './domain/usecases/sales-price-formula-data.orchestrator';
import { CqrsModule } from '@nestjs/cqrs';
import { UpdateSalesPriceFormulaManager } from './domain/usecases/managers/update-sales-price-formula.manager';
import { DetailSalesPriceFormulaManager } from './domain/usecases/managers/detail-sales-price-formula.manager';
import {
  SalesPriceFormulaModel,
  TransactionSettingModel,
} from './data/models/sales-price-formula.model';
import { TaxDataService } from '../tax/data/services/tax-data.service';
import { TaxModel } from '../tax/data/models/tax.model';
import { ItemModel } from 'src/modules/item-related/item/data/models/item.model';
import { UpdateTransactionSettingManager } from './domain/usecases/managers/update-transaction-setting.manager';
import { TransactionModel } from '../transaction/data/models/transaction.model';
import { CouchModule } from 'src/modules/configuration/couch/couch.module';

@Global()
@Module({
  imports: [
    ConfigModule.forRoot(),
    TypeOrmModule.forFeature(
      [
        SalesPriceFormulaModel,
        TransactionSettingModel,
        TransactionModel,
        TaxModel,
        ItemModel,
      ],
      CONNECTION_NAME.DEFAULT,
    ),
    CqrsModule,
    CouchModule,
  ],
  controllers: [
    SalesPriceFormulaDataController,
    SalesPriceFormulaReadController,
  ],
  providers: [
    DetailSalesPriceFormulaManager,
    UpdateSalesPriceFormulaManager,
    UpdateTransactionSettingManager,

    TaxDataService,
    SalesPriceFormulaDataService,
    SalesPriceFormulaReadService,
    TransactionSettingDataService,

    SalesPriceFormulaDataOrchestrator,
    SalesPriceFormulaReadOrchestrator,
  ],
  exports: [SalesPriceFormulaDataService, SalesPriceFormulaReadService],
})
export class SalesPriceFormulaModule {}
