mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 22:00:31 +00:00
add server to monorepo.
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import { Service, Inject } from 'typedi';
|
||||
import events from '@/subscribers/events';
|
||||
import { MutateBaseCurrencyAccounts } from '../MutateBaseCurrencyAccounts';
|
||||
|
||||
@Service()
|
||||
export class MutateBaseCurrencyAccountsSubscriber {
|
||||
@Inject()
|
||||
public mutateBaseCurrencyAccounts: MutateBaseCurrencyAccounts;
|
||||
|
||||
/**
|
||||
* Attaches the events with handles.
|
||||
* @param bus
|
||||
*/
|
||||
attach(bus) {
|
||||
bus.subscribe(
|
||||
events.organization.baseCurrencyUpdated,
|
||||
this.updateAccountsCurrencyOnBaseCurrencyMutated
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the all accounts currency once the base currency
|
||||
* of the organization is mutated.
|
||||
*/
|
||||
private updateAccountsCurrencyOnBaseCurrencyMutated = async ({
|
||||
tenantId,
|
||||
organizationDTO,
|
||||
}) => {
|
||||
await this.mutateBaseCurrencyAccounts.mutateAllAccountsCurrency(
|
||||
tenantId,
|
||||
organizationDTO.baseCurrency
|
||||
);
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user