import { BaseBatchDeleteManager } from 'src/core/modules/domain/usecase/managers/base-batch-delete.manager';
import { TaxEntity } from '../../entities/tax.entity';
import {
  EventTopics,
  validateRelations,
} from 'src/core/strings/constants/interface.constants';
import { TaxModel } from '../../../data/models/tax.model';
import { TaxDeletedEvent } from '../../entities/event/tax-deleted.event';
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
import { Injectable } from '@nestjs/common';
import { validateUsedInFormula } from './helpers/validation.helper';

@Injectable()
export class BatchDeleteTaxManager extends BaseBatchDeleteManager<TaxEntity> {
  async beforeProcess(): Promise<void> {
    return;
  }

  async validateData(data: TaxEntity): Promise<void> {
    await validateUsedInFormula(
      this.dataServiceFirstOpt,
      data.name.toLowerCase(),
    );
    return;
  }

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

  get validateRelations(): validateRelations[] {
    return [];
  }

  get entityTarget(): any {
    return TaxModel;
  }

  get eventTopics(): EventTopics[] {
    return [
      {
        topic: TaxDeletedEvent,
      },
    ];
  }

  getResult(): BatchResult {
    return this.result;
  }
}
