Browse Source

Respect the accounts' currencies

pull/391/head
Thomas 4 years ago
parent
commit
37244425e4
  1. 28
      apps/api/src/services/exchange-rate-data.service.ts

28
apps/api/src/services/exchange-rate-data.service.ts

@ -168,28 +168,34 @@ export class ExchangeRateDataService {
private async prepareCurrencies(): Promise<string[]> { private async prepareCurrencies(): Promise<string[]> {
const currencies: string[] = []; const currencies: string[] = [];
const settings = await this.prismaService.settings.findMany({ (
await this.prismaService.account.findMany({
distinct: ['currency'], distinct: ['currency'],
orderBy: [{ currency: 'asc' }], orderBy: [{ currency: 'asc' }],
select: { currency: true } select: { currency: true }
})
).forEach((account) => {
currencies.push(account.currency);
}); });
settings.forEach((settingsItem) => { (
if (settingsItem.currency) { await this.prismaService.settings.findMany({
currencies.push(settingsItem.currency);
}
});
const symbolProfiles = await this.prismaService.symbolProfile.findMany({
distinct: ['currency'], distinct: ['currency'],
orderBy: [{ currency: 'asc' }], orderBy: [{ currency: 'asc' }],
select: { currency: true } select: { currency: true }
})
).forEach((userSettings) => {
currencies.push(userSettings.currency);
}); });
symbolProfiles.forEach((symbolProfile) => { (
if (symbolProfile.currency) { await this.prismaService.symbolProfile.findMany({
distinct: ['currency'],
orderBy: [{ currency: 'asc' }],
select: { currency: true }
})
).forEach((symbolProfile) => {
currencies.push(symbolProfile.currency); currencies.push(symbolProfile.currency);
}
}); });
return uniq(currencies).sort(); return uniq(currencies).sort();

Loading…
Cancel
Save