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,60 @@
import {
IBillPaymentEventCreatedPayload,
IBillPaymentEventDeletedPayload,
IBillPaymentEventEditedPayload,
} from '../types/BillPayments.types';
import { BillPaymentGLEntries } from '../commands/BillPaymentGLEntries';
import { Injectable } from '@nestjs/common';
import { OnEvent } from '@nestjs/event-emitter';
import { events } from '@/common/events/events';
@Injectable()
export class BillPaymentGLEntriesSubscriber {
constructor(
private readonly billPaymentGLEntries: BillPaymentGLEntries,
) {}
/**
* Handle bill payment writing journal entries once created.
*/
@OnEvent(events.billPayment.onCreated)
private async handleWriteJournalEntries({
billPayment,
trx,
}: IBillPaymentEventCreatedPayload) {
// Records the journal transactions after bills payment
// and change diff account balance.
await this.billPaymentGLEntries.writePaymentGLEntries(
billPayment.id,
trx
);
};
/**
* Handle bill payment re-writing journal entries once the payment transaction be edited.
*/
@OnEvent(events.billPayment.onEdited)
private async handleRewriteJournalEntriesOncePaymentEdited({
billPayment,
trx,
}: IBillPaymentEventEditedPayload) {
await this.billPaymentGLEntries.rewritePaymentGLEntries(
billPayment.id,
trx
);
};
/**
* Reverts journal entries once bill payment deleted.
*/
@OnEvent(events.billPayment.onDeleted)
private async handleRevertJournalEntries({
billPaymentId,
trx,
}: IBillPaymentEventDeletedPayload) {
await this.billPaymentGLEntries.revertPaymentGLEntries(
billPaymentId,
trx
);
};
}