mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 12:50:38 +00:00
feat(nestjs): migrate to NestJS
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import { OnEvent } from '@nestjs/event-emitter';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { CashflowTransactionsActivateBranches } from '../../Integrations/Cashflow/CashflowActivateBranches';
|
||||
import { IBranchesActivatedPayload } from '../../Branches.types';
|
||||
import { events } from '@/common/events/events';
|
||||
|
||||
@Injectable()
|
||||
export class CreditNoteActivateBranchesSubscriber {
|
||||
constructor(
|
||||
private readonly cashflowActivateBranches: CashflowTransactionsActivateBranches,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Updates accounts transactions with the primary branch once
|
||||
* the multi-branches is activated.
|
||||
* @param {IBranchesActivatedPayload}
|
||||
*/
|
||||
@OnEvent(events.branch.onActivated)
|
||||
async updateCashflowWithBranchOnActivated({
|
||||
|
||||
primaryBranch,
|
||||
trx,
|
||||
}: IBranchesActivatedPayload) {
|
||||
await this.cashflowActivateBranches.updateCashflowTransactionsWithBranch(
|
||||
primaryBranch.id,
|
||||
trx
|
||||
);
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
import { events } from '@/common/events/events';
|
||||
import { OnEvent } from '@nestjs/event-emitter';
|
||||
import { IBranchesActivatedPayload } from '../../Branches.types';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { CreditNoteActivateBranches } from '../../integrations/Sales/CreditNoteBranchesActivate';
|
||||
|
||||
@Injectable()
|
||||
export class CreditNoteActivateBranchesSubscriber {
|
||||
constructor(
|
||||
private readonly creditNotesActivateBranches: CreditNoteActivateBranches,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Updates accounts transactions with the primary branch once
|
||||
* the multi-branches is activated.
|
||||
* @param {IBranchesActivatedPayload}
|
||||
*/
|
||||
@OnEvent(events.branch.onActivated)
|
||||
async updateCreditNoteWithBranchOnActivated({
|
||||
primaryBranch,
|
||||
trx,
|
||||
}: IBranchesActivatedPayload) {
|
||||
await this.creditNotesActivateBranches.updateCreditsWithBranch(
|
||||
primaryBranch.id,
|
||||
trx
|
||||
);
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
import { IBranchesActivatedPayload } from '../../Branches.types';
|
||||
import { events } from '@/common/events/events';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { ExpensesActivateBranches } from '../../Integrations/Expense/ExpensesActivateBranches';
|
||||
import { OnEvent } from '@nestjs/event-emitter';
|
||||
|
||||
@Injectable()
|
||||
export class ExpenseActivateBranchesSubscriber {
|
||||
constructor(
|
||||
private readonly expensesActivateBranches: ExpensesActivateBranches,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Updates accounts transactions with the primary branch once
|
||||
* the multi-branches is activated.
|
||||
* @param {IBranchesActivatedPayload}
|
||||
*/
|
||||
@OnEvent(events.branch.onActivated)
|
||||
async updateExpensesWithBranchOnActivated({
|
||||
primaryBranch,
|
||||
trx,
|
||||
}: IBranchesActivatedPayload) {
|
||||
await this.expensesActivateBranches.updateExpensesWithBranch(
|
||||
primaryBranch.id,
|
||||
trx,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
import { BillPaymentsActivateBranches } from '../../Integrations/Purchases/PaymentMadeBranchesActivate';
|
||||
import { OnEvent } from '@nestjs/event-emitter';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { events } from '@/common/events/events';
|
||||
import { IBranchesActivatedPayload } from '../../Branches.types';
|
||||
|
||||
@Injectable()
|
||||
export class PaymentMadeActivateBranchesSubscriber {
|
||||
constructor(
|
||||
private readonly paymentsActivateBranches: BillPaymentsActivateBranches,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Updates accounts transactions with the primary branch once
|
||||
* the multi-branches is activated.
|
||||
* @param {IBranchesActivatedPayload}
|
||||
*/
|
||||
@OnEvent(events.branch.onActivated)
|
||||
async updatePaymentsWithBranchOnActivated({
|
||||
primaryBranch,
|
||||
trx,
|
||||
}: IBranchesActivatedPayload) {
|
||||
await this.paymentsActivateBranches.updateBillPaymentsWithBranch(
|
||||
primaryBranch.id,
|
||||
trx,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
import { events } from '@/common/events/events';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { OnEvent } from '@nestjs/event-emitter';
|
||||
import { IBranchesActivatedPayload } from '../../Branches.types';
|
||||
import { PaymentReceiveActivateBranches } from '../../integrations/Sales/PaymentReceiveBranchesActivate';
|
||||
|
||||
@Injectable()
|
||||
export class PaymentReceiveActivateBranchesSubscriber {
|
||||
constructor(
|
||||
private readonly paymentsActivateBranches: PaymentReceiveActivateBranches,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Updates accounts transactions with the primary branch once
|
||||
* the multi-branches is activated.
|
||||
* @param {IBranchesActivatedPayload}
|
||||
*/
|
||||
@OnEvent(events.branch.onActivated)
|
||||
async updateCreditNoteWithBranchOnActivated({
|
||||
primaryBranch,
|
||||
trx,
|
||||
}: IBranchesActivatedPayload) {
|
||||
await this.paymentsActivateBranches.updatePaymentsWithBranch(
|
||||
primaryBranch.id,
|
||||
trx
|
||||
);
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
import { OnEvent } from '@nestjs/event-emitter';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { IBranchesActivatedPayload } from '../../Branches.types';
|
||||
import { events } from '@/common/events/events';
|
||||
import { SaleEstimateActivateBranches } from '../../integrations/Sales/SaleEstimatesBranchesActivate';
|
||||
|
||||
@Injectable()
|
||||
export class SaleEstimatesActivateBranchesSubscriber {
|
||||
constructor(
|
||||
private readonly estimatesActivateBranches: SaleEstimateActivateBranches,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Updates accounts transactions with the primary branch once
|
||||
* the multi-branches is activated.
|
||||
* @param {IBranchesActivatedPayload}
|
||||
*/
|
||||
@OnEvent(events.branch.onActivated)
|
||||
async updateEstimatesWithBranchOnActivated({
|
||||
primaryBranch,
|
||||
trx,
|
||||
}: IBranchesActivatedPayload) {
|
||||
await this.estimatesActivateBranches.updateEstimatesWithBranch(
|
||||
primaryBranch.id,
|
||||
trx
|
||||
);
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
import { events } from '@/common/events/events';
|
||||
import { SaleInvoiceActivateBranches } from '../../Integrations/Sales/SaleInvoiceBranchesActivate';
|
||||
import { OnEvent } from '@nestjs/event-emitter';
|
||||
import { IBranchesActivatedPayload } from '../../Branches.types';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
@Injectable()
|
||||
export class SaleInvoicesActivateBranchesSubscriber {
|
||||
constructor(
|
||||
private readonly invoicesActivateBranches: SaleInvoiceActivateBranches,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Updates accounts transactions with the primary branch once
|
||||
* the multi-branches is activated.
|
||||
* @param {IBranchesActivatedPayload}
|
||||
*/
|
||||
@OnEvent(events.branch.onActivated)
|
||||
async updateInvoicesWithBranchOnActivated({
|
||||
primaryBranch,
|
||||
trx,
|
||||
}: IBranchesActivatedPayload) {
|
||||
await this.invoicesActivateBranches.updateInvoicesWithBranch(
|
||||
primaryBranch.id,
|
||||
trx
|
||||
);
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
import { OnEvent } from '@nestjs/event-emitter';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { events } from '@/common/events/events';
|
||||
import { IBranchesActivatedPayload } from '../../Branches.types';
|
||||
import { SaleReceiptActivateBranches } from '../../integrations/Sales/SaleReceiptBranchesActivate';
|
||||
|
||||
@Injectable()
|
||||
export class SaleReceiptsActivateBranchesSubscriber {
|
||||
constructor(
|
||||
private readonly receiptsActivateBranches: SaleReceiptActivateBranches,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Updates accounts transactions with the primary branch once
|
||||
* the multi-branches is activated.
|
||||
* @param {IBranchesActivatedPayload}
|
||||
*/
|
||||
@OnEvent(events.branch.onActivated)
|
||||
async updateReceiptsWithBranchOnActivated({
|
||||
primaryBranch,
|
||||
trx,
|
||||
}: IBranchesActivatedPayload) {
|
||||
await this.receiptsActivateBranches.updateReceiptsWithBranch(
|
||||
primaryBranch.id,
|
||||
trx,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user