Files
bigcapital/packages/server/src/modules/Branches/subscribers/Validators/CreditNoteRefundBranchSubscriber.ts
Ahmed Bouhuolia 04d065b969 wip
2026-01-24 13:59:43 +02:00

26 lines
948 B
TypeScript

import { Injectable } from '@nestjs/common';
import { OnEvent } from '@nestjs/event-emitter';
import { ValidateBranchExistance } from '../../integrations/ValidateBranchExistance';
import { events } from '@/common/events/events';
import { IRefundCreditNoteCreatingPayload } from '@/modules/CreditNoteRefunds/types/CreditNoteRefunds.types';
@Injectable()
export class CreditNoteRefundBranchValidateSubscriber {
constructor(
private readonly validateBranchExistance: ValidateBranchExistance
) { }
/**
* Validate branch existance on refund credit note creating.
* @param {IRefundCreditNoteCreatingPayload} payload
*/
@OnEvent(events.creditNote.onRefundCreating, { suppressErrors: false })
async validateBranchExistanceOnCreditRefundCreating({
newCreditNoteDTO,
}: IRefundCreditNoteCreatingPayload) {
await this.validateBranchExistance.validateTransactionBranchWhenActive(
newCreditNoteDTO.branchId
);
}
}