Browse Source

Refactoring

pull/4486/head
Thomas Kaul 4 months ago
parent
commit
942803baf6
  1. 42
      apps/api/src/app/import/import.service.ts
  2. 1
      apps/api/src/app/order/interfaces/activities.interface.ts
  3. 8
      apps/api/src/app/portfolio/portfolio.service.ts
  4. 2
      apps/client/src/app/services/import-activities.service.ts

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

@ -126,8 +126,7 @@ export class ImportService {
unitPrice: marketPrice,
unitPriceInAssetProfileCurrency: marketPrice,
updatedAt: undefined,
userId: Account?.userId,
valueInBaseCurrency: 0
userId: Account?.userId
};
})
);
@ -419,43 +418,14 @@ export class ImportService {
});
});
const dataGatheringItems = uniqueActivities.flatMap(
({ currency, date, SymbolProfile }) => {
const activityDataGatheringItems = [
{
this.dataGatheringService.gatherSymbols({
dataGatheringItems: uniqueActivities.map(({ date, SymbolProfile }) => {
return {
date,
dataSource: SymbolProfile.dataSource,
symbol: SymbolProfile.symbol
}
];
if (currency !== SymbolProfile.currency) {
activityDataGatheringItems.push({
date,
dataSource:
this.dataProviderService.getDataSourceForExchangeRates(),
symbol: `${currency}${SymbolProfile.currency}`
});
}
if (
(currency ?? SymbolProfile.currency) !==
user.Settings.settings.baseCurrency
) {
activityDataGatheringItems.push({
date,
dataSource:
this.dataProviderService.getDataSourceForExchangeRates(),
symbol: `${currency ?? SymbolProfile.currency}${user.Settings.settings.baseCurrency}`
});
}
return activityDataGatheringItems;
}
);
this.dataGatheringService.gatherSymbols({
dataGatheringItems,
};
}),
priority: DATA_GATHERING_QUEUE_PRIORITY_HIGH
});
}

1
apps/api/src/app/order/interfaces/activities.interface.ts

@ -17,7 +17,6 @@ export interface Activity extends Order {
unitPriceInAssetProfileCurrency: number;
updateAccountBalance?: boolean;
value: number;
valueInBaseCurrency: number;
}
export interface ActivityError {

8
apps/api/src/app/portfolio/portfolio.service.ts

@ -246,10 +246,14 @@ export class PortfolioService {
activities: Activity[];
groupBy?: GroupBy;
}): Promise<InvestmentItem[]> {
let dividends = activities.map(({ date, valueInBaseCurrency }) => {
let dividends = activities.map(({ currency, date, value }) => {
return {
date: format(date, DATE_FORMAT),
investment: valueInBaseCurrency
investment: this.exchangeRateDataService.toCurrency(
value,
currency,
this.getUserCurrency()
)
};
});

2
apps/client/src/app/services/import-activities.service.ts

@ -138,12 +138,12 @@ export class ImportActivitiesService {
return {
accountId,
comment,
currency,
fee,
quantity,
type,
unitPrice,
updateAccountBalance,
currency: currency ?? SymbolProfile.currency,
dataSource: SymbolProfile.dataSource,
date: date.toString(),
symbol: SymbolProfile.symbol

Loading…
Cancel
Save