mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-15 04:10:32 +00:00
42 lines
1.3 KiB
TypeScript
42 lines
1.3 KiB
TypeScript
import { OnEvent } from '@nestjs/event-emitter';
|
|
import { Injectable } from '@nestjs/common';
|
|
import {
|
|
IBillPaymentCreatingPayload,
|
|
IBillPaymentEditingPayload,
|
|
} from '@/modules/BillPayments/types/BillPayments.types';
|
|
import { ValidateBranchExistance } from '../../integrations/ValidateBranchExistance';
|
|
import { events } from '@/common/events/events';
|
|
|
|
@Injectable()
|
|
export class PaymentMadeBranchValidateSubscriber {
|
|
constructor(
|
|
private readonly validateBranchExistance: ValidateBranchExistance,
|
|
) { }
|
|
|
|
/**
|
|
* Validate branch existance on estimate creating.
|
|
* @param {ISaleEstimateCreatedPayload} payload
|
|
*/
|
|
@OnEvent(events.billPayment.onCreating)
|
|
async validateBranchExistanceOnPaymentCreating({
|
|
billPaymentDTO,
|
|
}: IBillPaymentCreatingPayload) {
|
|
await this.validateBranchExistance.validateTransactionBranchWhenActive(
|
|
billPaymentDTO.branchId,
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Validate branch existance once estimate editing.
|
|
* @param {ISaleEstimateEditingPayload} payload
|
|
*/
|
|
@OnEvent(events.billPayment.onEditing)
|
|
async validateBranchExistanceOnPaymentEditing({
|
|
billPaymentDTO,
|
|
}: IBillPaymentEditingPayload) {
|
|
await this.validateBranchExistance.validateTransactionBranchWhenActive(
|
|
billPaymentDTO.branchId,
|
|
);
|
|
}
|
|
}
|