mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 13:20:31 +00:00
35 lines
874 B
TypeScript
35 lines
874 B
TypeScript
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
|
|
);
|
|
};
|
|
}
|