feat(nestjs): migrate to NestJS

This commit is contained in:
Ahmed Bouhuolia
2025-04-07 11:51:24 +02:00
parent f068218a16
commit 55fcc908ef
3779 changed files with 631 additions and 195332 deletions

View File

@@ -0,0 +1,41 @@
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,
);
}
}