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,61 @@
// import { Injectable } from '@nestjs/common';
// import { InjectModel } from '@nestjs/objection';
// import events from '@/subscribers/events';
// import {
// IVendorCreditApplyToBillDeletedPayload,
// IVendorCreditApplyToBillsCreatedPayload,
// } from '@/interfaces';
// import { ApplyVendorCreditSyncBillsService } from '../command/ApplyVendorCreditSyncBills.service';
// import { VendorCreditApplyToBill } from '../models/VendorCreditApplyToBill';
// @Injectable()
// export default class ApplyVendorCreditSyncBillsSubscriber {
// constructor(
// private readonly syncBillsWithVendorCredit: ApplyVendorCreditSyncBillsService,
// @InjectModel(VendorCreditApplyToBill)
// private readonly vendorCreditApplyToBillModel: typeof VendorCreditApplyToBill,
// ) {}
// /**
// * Attaches events with handlers.
// */
// attach(bus) {
// bus.subscribe(
// events.vendorCredit.onApplyToInvoicesCreated,
// this.incrementAppliedBillsOnceCreditCreated
// );
// bus.subscribe(
// events.vendorCredit.onApplyToInvoicesDeleted,
// this.decrementAppliedBillsOnceCreditDeleted
// );
// }
// /**
// * Increment credited amount of applied bills once the vendor credit transaction created.
// * @param {IVendorCreditApplyToBillsCreatedPayload} paylaod -
// */
// private incrementAppliedBillsOnceCreditCreated = async ({
// vendorCreditAppliedBills,
// trx,
// }: IVendorCreditApplyToBillsCreatedPayload) => {
// await this.syncBillsWithVendorCredit.incrementBillsCreditedAmount(
// vendorCreditAppliedBills,
// trx
// );
// };
// /**
// * Decrement credited amount of applied bills once the vendor credit
// * transaction delted.
// * @param {IVendorCreditApplyToBillDeletedPayload} payload
// */
// private decrementAppliedBillsOnceCreditDeleted = async ({
// oldCreditAppliedToBill,
// trx,
// }: IVendorCreditApplyToBillDeletedPayload) => {
// await this.syncBillsWithVendorCredit.decrementBillCreditedAmount(
// oldCreditAppliedToBill,
// trx
// );
// };
// }

View File

@@ -0,0 +1,70 @@
// import { Service, Inject } from 'typedi';
// import { sumBy } from 'lodash';
// import HasTenancyService from '@/services/Tenancy/TenancyService';
// import ApplyVendorCreditSyncInvoiced from '../command/ApplyVendorCreditSyncInvoiced.service';
// import events from '@/subscribers/events';
// import {
// IVendorCreditApplyToBillDeletedPayload,
// IVendorCreditApplyToBillsCreatedPayload,
// } from '../types/VendorCreditApplyBills.types';
// @Service()
// export default class ApplyVendorCreditSyncInvoicedSubscriber {
// @Inject()
// tenancy: HasTenancyService;
// @Inject()
// syncCreditWithInvoiced: ApplyVendorCreditSyncInvoiced;
// /**
// * Attaches events with handlers.
// */
// attach(bus) {
// bus.subscribe(
// events.vendorCredit.onApplyToInvoicesCreated,
// this.incrementBillInvoicedOnceCreditApplied
// );
// bus.subscribe(
// events.vendorCredit.onApplyToInvoicesDeleted,
// this.decrementBillInvoicedOnceCreditApplyDeleted
// );
// }
// /**
// * Increment vendor credit invoiced amount once the apply transaction created.
// * @param {IVendorCreditApplyToBillsCreatedPayload} payload -
// */
// private incrementBillInvoicedOnceCreditApplied = async ({
// vendorCredit,
// tenantId,
// vendorCreditAppliedBills,
// trx,
// }: IVendorCreditApplyToBillsCreatedPayload) => {
// const amount = sumBy(vendorCreditAppliedBills, 'amount');
// await this.syncCreditWithInvoiced.incrementVendorCreditInvoicedAmount(
// tenantId,
// vendorCredit.id,
// amount,
// trx
// );
// };
// /**
// * Decrement vendor credit invoiced amount once the apply transaction deleted.
// * @param {IVendorCreditApplyToBillDeletedPayload} payload -
// */
// private decrementBillInvoicedOnceCreditApplyDeleted = async ({
// tenantId,
// vendorCredit,
// oldCreditAppliedToBill,
// trx,
// }: IVendorCreditApplyToBillDeletedPayload) => {
// await this.syncCreditWithInvoiced.decrementVendorCreditInvoicedAmount(
// tenantId,
// oldCreditAppliedToBill.vendorCreditId,
// oldCreditAppliedToBill.amount,
// trx
// );
// };
// }