From 7e28e42995424cf17d4680e93507039b18734ddc Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Sat, 16 Mar 2024 18:59:23 +0100 Subject: [PATCH] Feature/exclude fees from holdings (#3160) --- .../api/src/app/portfolio/portfolio.service.ts | 18 ++++++++++++------ libs/common/src/lib/helper.ts | 2 +- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/apps/api/src/app/portfolio/portfolio.service.ts b/apps/api/src/app/portfolio/portfolio.service.ts index c5f8feb4a..5b36f91fa 100644 --- a/apps/api/src/app/portfolio/portfolio.service.ts +++ b/apps/api/src/app/portfolio/portfolio.service.ts @@ -356,16 +356,22 @@ export class PortfolioService { (user.Settings?.settings as UserSettings)?.emergencyFund ?? 0 ); + let types = getAllActivityTypes().filter((activityType) => { + return activityType !== 'FEE'; + }); + + if (withLiabilities === false) { + types = types.filter((activityType) => { + return activityType !== 'LIABILITY'; + }); + } + const { activities, portfolioOrders, transactionPoints } = await this.getTransactionPoints({ filters, + types, userId, - withExcludedAccounts, - types: withLiabilities - ? undefined - : getAllActivityTypes().filter((activityType) => { - return activityType !== 'LIABILITY'; - }) + withExcludedAccounts }); const portfolioCalculator = new PortfolioCalculator({ diff --git a/libs/common/src/lib/helper.ts b/libs/common/src/lib/helper.ts index c52ec9ca5..e70137336 100644 --- a/libs/common/src/lib/helper.ts +++ b/libs/common/src/lib/helper.ts @@ -139,7 +139,7 @@ export function extractNumberFromString({ } export function getAllActivityTypes(): ActivityType[] { - return ['BUY', 'DIVIDEND', 'FEE', 'ITEM', 'LIABILITY', 'SELL']; + return Object.values(ActivityType); } export function getAssetProfileIdentifier({ dataSource, symbol }: UniqueAsset) {