import { Injectable } from '@nestjs/common';
import { IndexTaxManager } from './managers/index-tax.manager';
import { TaxReadService } from '../../data/services/tax-read.service';
import { TaxEntity } from '../entities/tax.entity';
import { PaginationResponse } from 'src/core/response/domain/ok-response.interface';
import { BaseReadOrchestrator } from 'src/core/modules/domain/usecase/orchestrators/base-read.orchestrator';
import { DetailTaxManager } from './managers/detail-tax.manager';
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
import { IndexTaxFormulaManager } from './managers/index-tax-formula.manager';

@Injectable()
export class TaxReadOrchestrator extends BaseReadOrchestrator<TaxEntity> {
  constructor(
    private indexManager: IndexTaxManager,
    private formulaManager: IndexTaxFormulaManager,
    private detailManager: DetailTaxManager,
    private serviceData: TaxReadService,
  ) {
    super();
  }

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

  async formula(params): Promise<PaginationResponse<TaxEntity>> {
    this.formulaManager.setFilterParam(params);
    this.formulaManager.setService(this.serviceData, TABLE_NAME.TAX);
    await this.formulaManager.execute();
    return this.formulaManager.getResult();
  }

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