import { Injectable } from '@nestjs/common';
import { BaseDeleteManager } from 'src/core/modules/domain/usecase/managers/base-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 { validateUsedInFormula } from './helpers/validation.helper';

@Injectable()
export class DeleteTaxManager extends BaseDeleteManager<TaxEntity> {
  getResult(): string {
    return `Success`;
  }

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

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

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

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

  get entityTarget(): any {
    return TaxModel;
  }

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