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

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

  get specificFilter(): Param[] {
    return [
      {
        cols: `${this.tableName}.status::text`,
        isStatus: true,
        data: [`'active'`],
      },
    ];
  }

  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}.name`,
    ];
  }
}
