import { Injectable } from '@nestjs/common';
import { SalesPriceFormulaReadService } from '../../data/services/sales-price-formula-read.service';
import { SalesPriceFormulaEntity } from '../entities/sales-price-formula.entity';
import { DetailSalesPriceFormulaManager } from './managers/detail-sales-price-formula.manager';
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';

@Injectable()
export class SalesPriceFormulaReadOrchestrator {
  constructor(
    private detailManager: DetailSalesPriceFormulaManager,
    private serviceData: SalesPriceFormulaReadService,
  ) {}

  async detail(): Promise<SalesPriceFormulaEntity> {
    this.detailManager.setData('');
    this.detailManager.setService(this.serviceData, TABLE_NAME.PRICE_FORMULA);
    await this.detailManager.execute();
    return this.detailManager.getResult();
  }

  async getTransactionSetting(): Promise<any> {
    try {
      return await this.serviceData.getTransactionSetting();
    } catch (error) {
      throw error;
    }
  }
}
