Feature/respect account currency in exchange rate data service (#391)
* Respect the accounts' currencies * Update changelog
This commit is contained in:
parent
6333aa972d
commit
39d9828f9f
@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- Changed the navigation to always show the portfolio page
|
||||
- Migrated the data type of currencies from `enum` to `string` in the database
|
||||
- Supported unlimited currencies (instead of `CHF`, `EUR`, `GBP` and `USD`)
|
||||
- Respected the accounts' currencies in the exchange rate service
|
||||
|
||||
### Fixed
|
||||
|
||||
|
@ -168,28 +168,34 @@ export class ExchangeRateDataService {
|
||||
private async prepareCurrencies(): Promise<string[]> {
|
||||
const currencies: string[] = [];
|
||||
|
||||
const settings = await this.prismaService.settings.findMany({
|
||||
distinct: ['currency'],
|
||||
orderBy: [{ currency: 'asc' }],
|
||||
select: { currency: true }
|
||||
(
|
||||
await this.prismaService.account.findMany({
|
||||
distinct: ['currency'],
|
||||
orderBy: [{ currency: 'asc' }],
|
||||
select: { currency: true }
|
||||
})
|
||||
).forEach((account) => {
|
||||
currencies.push(account.currency);
|
||||
});
|
||||
|
||||
settings.forEach((settingsItem) => {
|
||||
if (settingsItem.currency) {
|
||||
currencies.push(settingsItem.currency);
|
||||
}
|
||||
(
|
||||
await this.prismaService.settings.findMany({
|
||||
distinct: ['currency'],
|
||||
orderBy: [{ currency: 'asc' }],
|
||||
select: { currency: true }
|
||||
})
|
||||
).forEach((userSettings) => {
|
||||
currencies.push(userSettings.currency);
|
||||
});
|
||||
|
||||
const symbolProfiles = await this.prismaService.symbolProfile.findMany({
|
||||
distinct: ['currency'],
|
||||
orderBy: [{ currency: 'asc' }],
|
||||
select: { currency: true }
|
||||
});
|
||||
|
||||
symbolProfiles.forEach((symbolProfile) => {
|
||||
if (symbolProfile.currency) {
|
||||
currencies.push(symbolProfile.currency);
|
||||
}
|
||||
(
|
||||
await this.prismaService.symbolProfile.findMany({
|
||||
distinct: ['currency'],
|
||||
orderBy: [{ currency: 'asc' }],
|
||||
select: { currency: true }
|
||||
})
|
||||
).forEach((symbolProfile) => {
|
||||
currencies.push(symbolProfile.currency);
|
||||
});
|
||||
|
||||
return uniq(currencies).sort();
|
||||
|
Loading…
x
Reference in New Issue
Block a user