From 30835ced885dd16657634cb5ff519e5cac55e04b Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Thu, 7 Jul 2022 21:06:12 +0200 Subject: [PATCH] Bugfix/fix holdings for basic users (#1064) * Fix holdings for basic users * Update changelog --- CHANGELOG.md | 4 +++ .../src/app/portfolio/portfolio.controller.ts | 25 ++++++++++++++----- .../allocations/allocations-page.html | 10 +++----- .../src/app/pages/public/public-page.html | 2 +- .../portfolio-proportion-chart.component.ts | 2 +- 5 files changed, 28 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b947347e3..efb69f2b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Improved the _Create Account_ link in the _Live Demo_ - Upgraded `ngx-markdown` from version `13.0.0` to `14.0.1` +### Fixed + +- Fixed an issue in the _Holdings_ section for users without a subscription + ## 1.166.0 - 30.06.2022 ### Added diff --git a/apps/api/src/app/portfolio/portfolio.controller.ts b/apps/api/src/app/portfolio/portfolio.controller.ts index ee11e4d1b..70ecbe071 100644 --- a/apps/api/src/app/portfolio/portfolio.controller.ts +++ b/apps/api/src/app/portfolio/portfolio.controller.ts @@ -190,14 +190,27 @@ export class PortfolioController { } } - const isBasicUser = - this.configurationService.get('ENABLE_FEATURE_SUBSCRIPTION') && - this.request.user.subscription.type === 'Basic'; + let hasDetails = true; + if (this.configurationService.get('ENABLE_FEATURE_SUBSCRIPTION')) { + hasDetails = this.request.user.subscription.type === 'Premium'; + } + + for (const [symbol, portfolioPosition] of Object.entries(holdings)) { + holdings[symbol] = { + ...portfolioPosition, + assetClass: hasDetails ? portfolioPosition.assetClass : undefined, + assetSubClass: hasDetails ? portfolioPosition.assetSubClass : undefined, + countries: hasDetails ? portfolioPosition.countries : [], + currency: hasDetails ? portfolioPosition.currency : undefined, + markets: hasDetails ? portfolioPosition.markets : undefined, + sectors: hasDetails ? portfolioPosition.sectors : [] + }; + } return { accounts, hasError, - holdings: isBasicUser ? {} : holdings + holdings }; } @@ -340,8 +353,8 @@ export class PortfolioController { portfolioPublicDetails.holdings[symbol] = { allocationCurrent: portfolioPosition.value / totalValue, countries: hasDetails ? portfolioPosition.countries : [], - currency: portfolioPosition.currency, - markets: portfolioPosition.markets, + currency: hasDetails ? portfolioPosition.currency : undefined, + markets: hasDetails ? portfolioPosition.markets : undefined, name: portfolioPosition.name, netPerformancePercent: portfolioPosition.netPerformancePercent, sectors: hasDetails ? portfolioPosition.sectors : [], diff --git a/apps/client/src/app/pages/portfolio/allocations/allocations-page.html b/apps/client/src/app/pages/portfolio/allocations/allocations-page.html index 869148b5c..baa01aa32 100644 --- a/apps/client/src/app/pages/portfolio/allocations/allocations-page.html +++ b/apps/client/src/app/pages/portfolio/allocations/allocations-page.html @@ -94,13 +94,9 @@
- By Position + + By Holding - Positions + Holdings { let lightnessRatio = 0.2; - Object.keys(item.subCategory).forEach((subCategory) => { + Object.keys(item.subCategory ?? {}).forEach((subCategory) => { backgroundColorSubCategory.push( Color(item.color).lighten(lightnessRatio).hex() );