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

Loading…
Cancel
Save