mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 05:10:31 +00:00
25 lines
748 B
TypeScript
25 lines
748 B
TypeScript
import { OnEvent } from '@nestjs/event-emitter';
|
|
import { Injectable } from '@nestjs/common';
|
|
import { events } from '@/common/events/events';
|
|
import { MutateBaseCurrencyAccounts } from '../MutateBaseCurrencyAccounts';
|
|
|
|
@Injectable()
|
|
export class MutateBaseCurrencyAccountsSubscriber {
|
|
constructor(
|
|
public readonly mutateBaseCurrencyAccounts: MutateBaseCurrencyAccounts,
|
|
) {}
|
|
|
|
/**
|
|
* Updates the all accounts currency once the base currency
|
|
* of the organization is mutated.
|
|
*/
|
|
@OnEvent(events.organization.baseCurrencyUpdated)
|
|
async updateAccountsCurrencyOnBaseCurrencyMutated({
|
|
organizationDTO,
|
|
}) {
|
|
await this.mutateBaseCurrencyAccounts.mutateAllAccountsCurrency(
|
|
organizationDTO.baseCurrency
|
|
);
|
|
};
|
|
}
|