import { BaseBatchUpdateStatusManager } from 'src/core/modules/domain/usecase/managers/base-batch-update-status.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 { TaxChangeStatusEvent } from '../../entities/event/tax-change-status.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 BatchInactiveTaxManager extends BaseBatchUpdateStatusManager<TaxEntity> {
  // dataServiceFirstOpt adalah formula service

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

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

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

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

  get entityTarget(): any {
    return TaxModel;
  }

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

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