import { Injectable } from '@nestjs/common';
import { IndexReconciliationManager } from './managers/index-reconciliation.manager';
import { PaginationResponse } from 'src/core/response/domain/ok-response.interface';
import { BaseReadOrchestrator } from 'src/core/modules/domain/usecase/orchestrators/base-read.orchestrator';
import { DetailReconciliationManager } from './managers/detail-reconciliation.manager';
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
import { TransactionEntity } from 'src/modules/transaction/transaction/domain/entities/transaction.entity';
import { TransactionReadService } from 'src/modules/transaction/transaction/data/services/transaction-read.service';

@Injectable()
export class ReconciliationReadOrchestrator extends BaseReadOrchestrator<TransactionEntity> {
  constructor(
    private indexManager: IndexReconciliationManager,
    private detailManager: DetailReconciliationManager,
    private serviceData: TransactionReadService,
  ) {
    super();
  }

  async index(params): Promise<PaginationResponse<TransactionEntity>> {
    this.indexManager.setFilterParam(params);
    this.indexManager.setService(this.serviceData, TABLE_NAME.TRANSACTION);
    await this.indexManager.execute();
    return this.indexManager.getResult();
  }

  async detail(dataId: string): Promise<TransactionEntity> {
    this.detailManager.setData(dataId);
    this.detailManager.setService(this.serviceData, TABLE_NAME.TRANSACTION);
    await this.detailManager.execute();
    return this.detailManager.getResult();
  }
}
