mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 22:00:31 +00:00
feat(nestjs): migrate to NestJS
This commit is contained in:
@@ -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
|
||||
// );
|
||||
// };
|
||||
// }
|
||||
@@ -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
|
||||
// );
|
||||
// };
|
||||
// }
|
||||
Reference in New Issue
Block a user