Browse Source

Refactoring

pull/4486/head
Thomas Kaul 4 months ago
parent
commit
942803baf6
  1. 46
      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

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

@ -126,8 +126,7 @@ export class ImportService {
unitPrice: marketPrice, unitPrice: marketPrice,
unitPriceInAssetProfileCurrency: marketPrice, unitPriceInAssetProfileCurrency: marketPrice,
updatedAt: undefined, updatedAt: undefined,
userId: Account?.userId, userId: Account?.userId
valueInBaseCurrency: 0
}; };
}) })
); );
@ -419,43 +418,14 @@ export class ImportService {
}); });
}); });
const dataGatheringItems = uniqueActivities.flatMap(
({ currency, date, SymbolProfile }) => {
const activityDataGatheringItems = [
{
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({ this.dataGatheringService.gatherSymbols({
dataGatheringItems, dataGatheringItems: uniqueActivities.map(({ date, SymbolProfile }) => {
return {
date,
dataSource: SymbolProfile.dataSource,
symbol: SymbolProfile.symbol
};
}),
priority: DATA_GATHERING_QUEUE_PRIORITY_HIGH 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; unitPriceInAssetProfileCurrency: number;
updateAccountBalance?: boolean; updateAccountBalance?: boolean;
value: number; value: number;
valueInBaseCurrency: number;
} }
export interface ActivityError { export interface ActivityError {

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

@ -246,10 +246,14 @@ export class PortfolioService {
activities: Activity[]; activities: Activity[];
groupBy?: GroupBy; groupBy?: GroupBy;
}): Promise<InvestmentItem[]> { }): Promise<InvestmentItem[]> {
let dividends = activities.map(({ date, valueInBaseCurrency }) => { let dividends = activities.map(({ currency, date, value }) => {
return { return {
date: format(date, DATE_FORMAT), 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 { return {
accountId, accountId,
comment, comment,
currency,
fee, fee,
quantity, quantity,
type, type,
unitPrice, unitPrice,
updateAccountBalance, updateAccountBalance,
currency: currency ?? SymbolProfile.currency,
dataSource: SymbolProfile.dataSource, dataSource: SymbolProfile.dataSource,
date: date.toString(), date: date.toString(),
symbol: SymbolProfile.symbol symbol: SymbolProfile.symbol

Loading…
Cancel
Save