mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 22:30:31 +00:00
spelling: activate
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
import { IBranchesActivatedPayload } from '@/interfaces';
|
||||
import { Service, Inject } from 'typedi';
|
||||
import events from '@/subscribers/events';
|
||||
import { CashflowTransactionsActivateBranches } from '../../Integrations/Cashflow/CashflowActivateBranches';
|
||||
|
||||
@Service()
|
||||
export class CreditNoteActivateBranchesSubscriber {
|
||||
@Inject()
|
||||
private cashflowActivateBranches: CashflowTransactionsActivateBranches;
|
||||
|
||||
/**
|
||||
* Attaches events with handlers.
|
||||
*/
|
||||
public attach(bus) {
|
||||
bus.subscribe(
|
||||
events.branch.onActivated,
|
||||
this.updateCashflowWithBranchOnActivated
|
||||
);
|
||||
return bus;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates accounts transactions with the primary branch once
|
||||
* the multi-branches is activated.
|
||||
* @param {IBranchesActivatedPayload}
|
||||
*/
|
||||
private updateCashflowWithBranchOnActivated = async ({
|
||||
tenantId,
|
||||
primaryBranch,
|
||||
trx,
|
||||
}: IBranchesActivatedPayload) => {
|
||||
await this.cashflowActivateBranches.updateCashflowTransactionsWithBranch(
|
||||
tenantId,
|
||||
primaryBranch.id,
|
||||
trx
|
||||
);
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user