mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-14 03:40:31 +00:00
26 lines
948 B
TypeScript
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
|
|
);
|
|
}
|
|
}
|