Feature/remove accounts from holding endpoint (#3765)

* Clean up accounts
pull/3770/head
Thomas Kaul 3 months ago committed by GitHub
parent d236ecfe85
commit 9fb80e5067
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -5,10 +5,9 @@ import {
HistoricalDataItem HistoricalDataItem
} from '@ghostfolio/common/interfaces'; } from '@ghostfolio/common/interfaces';
import { Account, Tag } from '@prisma/client'; import { Tag } from '@prisma/client';
export interface PortfolioHoldingDetail { export interface PortfolioHoldingDetail {
accounts: Account[];
averagePrice: number; averagePrice: number;
dataProviderInfo: DataProviderInfo; dataProviderInfo: DataProviderInfo;
dividendInBaseCurrency: number; dividendInBaseCurrency: number;

@ -73,7 +73,7 @@ import {
parseISO, parseISO,
set set
} from 'date-fns'; } from 'date-fns';
import { isEmpty, last, uniq, uniqBy } from 'lodash'; import { isEmpty, last, uniq } from 'lodash';
import { PortfolioCalculator } from './calculator/portfolio-calculator'; import { PortfolioCalculator } from './calculator/portfolio-calculator';
import { import {
@ -625,7 +625,6 @@ export class PortfolioService {
if (activities.length === 0) { if (activities.length === 0) {
return { return {
accounts: [],
averagePrice: undefined, averagePrice: undefined,
dataProviderInfo: undefined, dataProviderInfo: undefined,
dividendInBaseCurrency: undefined, dividendInBaseCurrency: undefined,
@ -699,15 +698,6 @@ export class PortfolioService {
); );
}); });
const accounts: PortfolioHoldingDetail['accounts'] = uniqBy(
activitiesOfPosition.filter(({ Account }) => {
return Account;
}),
'Account.id'
).map(({ Account }) => {
return Account;
});
const dividendYieldPercent = getAnnualizedPerformancePercent({ const dividendYieldPercent = getAnnualizedPerformancePercent({
daysInMarket: differenceInDays(new Date(), parseDate(firstBuyDate)), daysInMarket: differenceInDays(new Date(), parseDate(firstBuyDate)),
netPerformancePercentage: timeWeightedInvestment.eq(0) netPerformancePercentage: timeWeightedInvestment.eq(0)
@ -788,7 +778,6 @@ export class PortfolioService {
} }
return { return {
accounts,
firstBuyDate, firstBuyDate,
marketPrice, marketPrice,
maxPrice, maxPrice,
@ -883,7 +872,6 @@ export class PortfolioService {
maxPrice, maxPrice,
minPrice, minPrice,
SymbolProfile, SymbolProfile,
accounts: [],
averagePrice: 0, averagePrice: 0,
dataProviderInfo: undefined, dataProviderInfo: undefined,
dividendInBaseCurrency: 0, dividendInBaseCurrency: 0,

Loading…
Cancel
Save