mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 21:00:31 +00:00
When activating the multi-branches feature, existing bills, vendor credits, and bill payments were not being marked with the default primary branch. Changes: - Add missing @Inject decorators to BillActivateBranches, VendorCreditActivateBranches, and BillPaymentsActivateBranches services - Create BillBranchesActivateSubscriber to listen to onActivated event - Create VendorCreditBranchesActivateSubscriber to listen to onActivated event - Register BillPaymentsActivateBranches and PaymentMadeActivateBranchesSubscriber in BranchesModule - Add branch object to BillResponseDto for API responses - Add branch to BillTransformer includeAttributes Fixes: #935
29 lines
923 B
TypeScript
29 lines
923 B
TypeScript
import { IBranchesActivatedPayload } from '../../Branches.types';
|
|
import { events } from '@/common/events/events';
|
|
import { Injectable } from '@nestjs/common';
|
|
import { VendorCreditActivateBranches } from '../../integrations/Purchases/VendorCreditBranchesActivate';
|
|
import { OnEvent } from '@nestjs/event-emitter';
|
|
|
|
@Injectable()
|
|
export class VendorCreditBranchesActivateSubscriber {
|
|
constructor(
|
|
private readonly vendorCreditActivateBranches: VendorCreditActivateBranches,
|
|
) { }
|
|
|
|
/**
|
|
* Updates vendor credits transactions with the primary branch once
|
|
* the multi-branches is activated.
|
|
* @param {IBranchesActivatedPayload}
|
|
*/
|
|
@OnEvent(events.branch.onActivated)
|
|
async updateVendorCreditsWithBranchOnActivated({
|
|
primaryBranch,
|
|
trx,
|
|
}: IBranchesActivatedPayload) {
|
|
await this.vendorCreditActivateBranches.updateVendorCreditsWithBranch(
|
|
primaryBranch.id,
|
|
trx,
|
|
);
|
|
}
|
|
}
|