import { 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 { TransactionDataService } from './data/services/transaction-data.service';
import { TransactionReadService } from './data/services/transaction-read.service';
import { TransactionReadController } from './infrastructure/transaction-read.controller';
import { TransactionReadOrchestrator } from './domain/usecases/transaction-read.orchestrator';
import { TransactionDataController } from './infrastructure/transaction-data.controller';
import { TransactionDataOrchestrator } from './domain/usecases/transaction-data.orchestrator';
import { CreateTransactionManager } from './domain/usecases/managers/create-transaction.manager';
import { CqrsModule } from '@nestjs/cqrs';
import { IndexTransactionManager } from './domain/usecases/managers/index-transaction.manager';
import { DeleteTransactionManager } from './domain/usecases/managers/delete-transaction.manager';
import { UpdateTransactionManager } from './domain/usecases/managers/update-transaction.manager';
import { ConfirmTransactionManager } from './domain/usecases/managers/confirm-transaction.manager';
import { DetailTransactionManager } from './domain/usecases/managers/detail-transaction.manager';
import { BatchDeleteTransactionManager } from './domain/usecases/managers/batch-delete-transaction.manager';
import { BatchConfirmTransactionManager } from './domain/usecases/managers/batch-confirm-transaction.manager';
import { TransactionModel } from './data/models/transaction.model';
import {
  TransactionBreakdownTaxModel,
  TransactionItemBreakdownModel,
  TransactionItemModel,
  TransactionItemTaxModel,
} from './data/models/transaction-item.model';
import { TransactionTaxModel } from './data/models/transaction-tax.model';
import { CancelTransactionManager } from './domain/usecases/managers/cancel-transaction.manager';
import { BatchCancelTransactionManager } from './domain/usecases/managers/batch-cancel-transaction.manager';
import { ConfirmDataTransactionManager } from './domain/usecases/managers/confirm-data-transaction.manager';
import { BatchConfirmDataTransactionManager } from './domain/usecases/managers/batch-confirm-data-transaction.manager';
import { PosTransactionHandler } from './domain/usecases/handlers/pos-transaction.handler';
import { TaxDataService } from '../tax/data/services/tax-data.service';
import { SalesPriceFormulaDataService } from '../sales-price-formula/data/services/sales-price-formula-data.service';
import {
  SalesPriceFormulaModel,
  TransactionSettingModel,
} from '../sales-price-formula/data/models/sales-price-formula.model';
import { TaxModel } from '../tax/data/models/tax.model';
import { SettledTransactionHandler } from './domain/usecases/handlers/settled-transaction.handler';
import { RefundUpdatedHandler } from './domain/usecases/handlers/refund-update.handler';
import { MidtransCallbackHandler } from './domain/usecases/handlers/midtrans-transaction-callback.handler';
import { PdfMakeManager } from 'src/modules/configuration/export/domain/managers/pdf-make.manager';
import { PaymentMethodDataService } from '../payment-method/data/services/payment-method-data.service';
import { PaymentMethodModel } from '../payment-method/data/models/payment-method.model';
import { TransactionDemographyModel } from './data/models/transaction-demography.model';
import { PriceCalculator } from './domain/usecases/calculator/price.calculator';
import { ItemModel } from 'src/modules/item-related/item/data/models/item.model';
import { CouchModule } from 'src/modules/configuration/couch/couch.module';
import { JWT_EXPIRED } from 'src/core/sessions/constants';
import { JWT_SECRET } from 'src/core/sessions/constants';
import { JwtModule } from '@nestjs/jwt';

@Module({
  exports: [
    TransactionReadService,
    TransactionDataService,
    CreateTransactionManager,
  ],
  imports: [
    ConfigModule.forRoot(),
    JwtModule.register({
      secret: JWT_SECRET,
      signOptions: { expiresIn: JWT_EXPIRED },
    }),
    TypeOrmModule.forFeature(
      [
        TransactionModel,
        TransactionItemModel,
        TransactionDemographyModel,
        TransactionItemBreakdownModel,
        TransactionTaxModel,
        TransactionItemTaxModel,
        TransactionBreakdownTaxModel,
        TransactionSettingModel,
        TaxModel,
        SalesPriceFormulaModel,
        PaymentMethodModel,
        ItemModel,
      ],
      CONNECTION_NAME.DEFAULT,
    ),
    CqrsModule,
    CouchModule,
  ],
  controllers: [TransactionDataController, TransactionReadController],
  providers: [
    PriceCalculator,
    RefundUpdatedHandler,
    PosTransactionHandler,
    MidtransCallbackHandler,
    SettledTransactionHandler,

    IndexTransactionManager,
    DetailTransactionManager,
    CreateTransactionManager,
    DeleteTransactionManager,
    UpdateTransactionManager,
    ConfirmTransactionManager,
    BatchDeleteTransactionManager,
    BatchConfirmTransactionManager,
    CancelTransactionManager,
    PdfMakeManager,
    BatchCancelTransactionManager,
    ConfirmDataTransactionManager,
    BatchConfirmDataTransactionManager,

    TransactionDataService,
    TransactionReadService,
    TaxDataService,
    SalesPriceFormulaDataService,
    PaymentMethodDataService,

    TransactionDataOrchestrator,
    TransactionReadOrchestrator,
  ],
})
export class TransactionModule {}
