From 7a364472c83662f770f9c319e1040590146dea2f Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Mon, 11 Mar 2024 20:16:56 +0100 Subject: [PATCH] Bugfix/fix liability issue in allocations (#3133) * Remove liabilities from allocations calculation * Update changelog --- CHANGELOG.md | 1 + apps/api/src/app/portfolio/portfolio.controller.ts | 7 +++++-- apps/api/src/app/portfolio/portfolio.service.ts | 4 ++-- .../home-summary/home-summary.component.ts | 2 +- apps/client/src/app/services/data.service.ts | 12 ++++++++++-- 5 files changed, 19 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 242dd9dfe..2fddca32c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Fixed an issue in the performance calculation caused by multiple `SELL` activities on the same day +- Fixed an issue in the calculation on the allocations page caused by liabilities ## 2.62.0 - 2024-03-09 diff --git a/apps/api/src/app/portfolio/portfolio.controller.ts b/apps/api/src/app/portfolio/portfolio.controller.ts index 748850204..557e8a5f5 100644 --- a/apps/api/src/app/portfolio/portfolio.controller.ts +++ b/apps/api/src/app/portfolio/portfolio.controller.ts @@ -76,8 +76,11 @@ export class PortfolioController { @Query('accounts') filterByAccounts?: string, @Query('assetClasses') filterByAssetClasses?: string, @Query('range') dateRange: DateRange = 'max', - @Query('tags') filterByTags?: string + @Query('tags') filterByTags?: string, + @Query('withLiabilities') withLiabilitiesParam = 'false' ): Promise { + const withLiabilities = withLiabilitiesParam === 'true'; + let hasDetails = true; let hasError = false; const hasReadRestrictedAccessPermission = @@ -101,8 +104,8 @@ export class PortfolioController { dateRange, filters, impersonationId, + withLiabilities, userId: this.request.user.id, - withLiabilities: true, withSummary: true }); diff --git a/apps/api/src/app/portfolio/portfolio.service.ts b/apps/api/src/app/portfolio/portfolio.service.ts index 9880abcc4..74d7b382a 100644 --- a/apps/api/src/app/portfolio/portfolio.service.ts +++ b/apps/api/src/app/portfolio/portfolio.service.ts @@ -146,8 +146,7 @@ export class PortfolioService { filters, withExcludedAccounts, impersonationId: userId, - userId: this.request.user.id, - withLiabilities: true + userId: this.request.user.id }) ]); @@ -393,6 +392,7 @@ export class PortfolioService { }); const holdings: PortfolioDetails['holdings'] = {}; + const totalValueInBaseCurrency = currentPositions.currentValueInBaseCurrency.plus( cashDetails.balanceInBaseCurrency diff --git a/apps/client/src/app/components/home-summary/home-summary.component.ts b/apps/client/src/app/components/home-summary/home-summary.component.ts index b67b67ce5..bb68a4627 100644 --- a/apps/client/src/app/components/home-summary/home-summary.component.ts +++ b/apps/client/src/app/components/home-summary/home-summary.component.ts @@ -102,7 +102,7 @@ export class HomeSummaryComponent implements OnDestroy, OnInit { this.isLoading = true; this.dataService - .fetchPortfolioDetails() + .fetchPortfolioDetails({ withLiabilities: true }) .pipe(takeUntil(this.unsubscribeSubject)) .subscribe(({ summary }) => { this.summary = summary; diff --git a/apps/client/src/app/services/data.service.ts b/apps/client/src/app/services/data.service.ts index 7741fd601..0c8781eb1 100644 --- a/apps/client/src/app/services/data.service.ts +++ b/apps/client/src/app/services/data.service.ts @@ -390,13 +390,21 @@ export class DataService { } public fetchPortfolioDetails({ - filters + filters, + withLiabilities = false }: { filters?: Filter[]; + withLiabilities?: boolean; } = {}): Observable { + let params = this.buildFiltersAsQueryParams({ filters }); + + if (withLiabilities) { + params = params.append('withLiabilities', withLiabilities); + } + return this.http .get('/api/v1/portfolio/details', { - params: this.buildFiltersAsQueryParams({ filters }) + params }) .pipe( map((response) => {