Browse Source

Feature/Use currencyAtDate where TODO was left

Signed-off-by: Anatoly Popov <me@aensidhe.ru>
pull/3672/head
Anatoly Popov 1 year ago
committed by Thomas Kaul
parent
commit
05733a541b
  1. 23
      apps/api/src/app/import/import.service.ts
  2. 20
      apps/api/src/app/order/order.service.ts

23
apps/api/src/app/import/import.service.ts

@ -82,7 +82,8 @@ export class ImportService {
const Account = this.isUniqueAccount(accounts) ? accounts[0] : undefined;
return Object.entries(dividends).map(([dateString, { marketPrice }]) => {
return await Promise.all(
Object.entries(dividends).map(async ([dateString, { marketPrice }]) => {
const quantity =
historicalData.find((historicalDataItem) => {
return historicalDataItem.date === dateString;
@ -129,13 +130,16 @@ export class ImportService {
unitPrice: marketPrice,
updatedAt: undefined,
userId: Account?.userId,
valueInBaseCurrency: this.exchangeRateDataService.toCurrency(
valueInBaseCurrency:
await this.exchangeRateDataService.toCurrencyAtDate(
value,
assetProfile.currency,
userCurrency
userCurrency,
date
)
};
});
})
);
} catch {
return [];
}
@ -432,17 +436,20 @@ export class ImportService {
...order,
error,
value,
feeInBaseCurrency: this.exchangeRateDataService.toCurrency(
feeInBaseCurrency: await this.exchangeRateDataService.toCurrencyAtDate(
fee,
assetProfile.currency,
userCurrency
userCurrency,
date
),
// @ts-ignore
SymbolProfile: assetProfile,
valueInBaseCurrency: this.exchangeRateDataService.toCurrency(
valueInBaseCurrency:
await this.exchangeRateDataService.toCurrencyAtDate(
value,
assetProfile.currency,
userCurrency
userCurrency,
date
)
});
}

20
apps/api/src/app/order/order.service.ts

@ -483,7 +483,8 @@ export class OrderService {
assetProfileIdentifiers
);
const activities = orders.map((order) => {
const activities = await Promise.all(
orders.map(async (order) => {
const assetProfile = assetProfiles.find(({ dataSource, symbol }) => {
return (
dataSource === order.SymbolProfile.dataSource &&
@ -496,21 +497,24 @@ export class OrderService {
return {
...order,
value,
// TODO: Use exchange rate of date
feeInBaseCurrency: this.exchangeRateDataService.toCurrency(
feeInBaseCurrency:
await this.exchangeRateDataService.toCurrencyAtDate(
order.fee,
order.SymbolProfile.currency,
userCurrency
userCurrency,
order.date
),
SymbolProfile: assetProfile,
// TODO: Use exchange rate of date
valueInBaseCurrency: this.exchangeRateDataService.toCurrency(
valueInBaseCurrency:
await this.exchangeRateDataService.toCurrencyAtDate(
value,
order.SymbolProfile.currency,
userCurrency
userCurrency,
order.date
)
};
});
})
);
return { activities, count };
}

Loading…
Cancel
Save