Browse Source

Clean up

pull/3243/head
Thomas Kaul 1 year ago
parent
commit
ed09335073
  1. 14
      apps/api/src/app/portfolio/portfolio.service.ts

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

@ -63,8 +63,7 @@ import {
DataSource,
Order,
Platform,
Prisma,
Tag
Prisma
} from '@prisma/client';
import { Big } from 'big.js';
import { isUUID } from 'class-validator';
@ -701,11 +700,8 @@ export class PortfolioService {
);
});
let tags: Tag[] = [];
if (orders.length <= 0) {
return {
tags,
accounts: [],
averagePrice: undefined,
dataProviderInfo: undefined,
@ -730,6 +726,7 @@ export class PortfolioService {
orders: [],
quantity: undefined,
SymbolProfile: undefined,
tags: [],
transactionCount: undefined,
value: undefined
};
@ -741,16 +738,12 @@ export class PortfolioService {
const portfolioCalculator = this.calculatorFactory.createCalculator({
activities: orders.filter((order) => {
tags = tags.concat(order.tags);
return ['BUY', 'DIVIDEND', 'ITEM', 'SELL'].includes(order.type);
}),
calculationType: PerformanceCalculationType.TWR,
currency: userCurrency
});
tags = uniqBy(tags, 'id');
const portfolioStart = portfolioCalculator.getStartDate();
const transactionPoints = portfolioCalculator.getTransactionPoints();
@ -771,6 +764,7 @@ export class PortfolioService {
firstBuyDate,
marketPrice,
quantity,
tags,
timeWeightedInvestment,
timeWeightedInvestmentWithCurrencyEffect,
transactionCount
@ -947,7 +941,6 @@ export class PortfolioService {
minPrice,
orders,
SymbolProfile,
tags,
accounts: [],
averagePrice: 0,
dataProviderInfo: undefined,
@ -967,6 +960,7 @@ export class PortfolioService {
netPerformancePercentWithCurrencyEffect: undefined,
netPerformanceWithCurrencyEffect: undefined,
quantity: 0,
tags: [],
transactionCount: undefined,
value: 0
};

Loading…
Cancel
Save