import { Injectable } from '@nestjs/common';
import {
  Param,
  RelationParam,
} from 'src/core/modules/domain/entities/base-filter.entity';
import { SalesPriceFormulaEntity } from 'src/modules/transaction/sales-price-formula/domain/entities/sales-price-formula.entity';
import { BaseIndexManager } from 'src/core/modules/domain/usecase/managers/base-index.manager';
import { SelectQueryBuilder } from 'typeorm';

@Injectable()
export class IndexProfitShareFormulaManager extends BaseIndexManager<SalesPriceFormulaEntity> {
  setQueryFilter(
    queryBuilder: SelectQueryBuilder<SalesPriceFormulaEntity>,
  ): SelectQueryBuilder<SalesPriceFormulaEntity> {
    return queryBuilder;
  }

  get specificFilter(): Param[] {
    return [];
  }

  async prepareData(): Promise<void> {
    return;
  }

  async beforeProcess(): Promise<void> {
    return;
  }

  async afterProcess(): Promise<void> {
    return;
  }

  get relations(): RelationParam {
    return {
      // relation only join (for query purpose)
      joinRelations: [],

      // relation join and select (relasi yang ingin ditampilkan),
      selectRelations: [],

      // relation yang hanya ingin dihitung (akan return number)
      countRelations: [],
    };
  }

  get selects(): string[] {
    // return [];
    return [
      `${this.tableName}.id`,
      `${this.tableName}.formula_render`,
      `${this.tableName}.formula_string`,
      `${this.tableName}.value_for`,
    ];
  }
}
