Skip to content

Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍

Bugfix/fix holdings for basic users (#1064)

Thomas Kaul30835ced885d
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b947347e38..efb69f2b95 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 ee11e4d1b2..70ecbe071f 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 869148b5c5..baa01aa32f 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 @@
<div class="col-md-12 allocations-by-symbol">
<mat-card class="mb-3">
<mat-card-header class="overflow-hidden w-100">
- <mat-card-title class="align-items-center d-flex text-truncate"
- ><span i18n>By Position</span
- ><gf-premium-indicator
- *ngIf="user?.subscription?.type === 'Basic'"
- class="ml-1"
- ></gf-premium-indicator
- ></mat-card-title>
+ <mat-card-title class="align-items-center d-flex text-truncate" i18n>
+ By Holding</mat-card-title
+ >
<gf-toggle
[defaultValue]="period"
[isLoading]="false"
diff --git a/apps/client/src/app/pages/public/public-page.html b/apps/client/src/app/pages/public/public-page.html
index 5afb4b8c1c..5746d68a51 100644
--- a/apps/client/src/app/pages/public/public-page.html
+++ b/apps/client/src/app/pages/public/public-page.html
@@ -10,7 +10,7 @@
<div class="col-md-12 allocations-by-symbol">
<mat-card class="mb-3">
<mat-card-header class="overflow-hidden w-100">
- <mat-card-title class="text-truncate" i18n>Positions</mat-card-title>
+ <mat-card-title class="text-truncate" i18n>Holdings</mat-card-title>
</mat-card-header>
<mat-card-content>
<gf-portfolio-proportion-chart
diff --git a/libs/ui/src/lib/portfolio-proportion-chart/portfolio-proportion-chart.component.ts b/libs/ui/src/lib/portfolio-proportion-chart/portfolio-proportion-chart.component.ts
index f8e43fa5eb..905cfd91d6 100644
--- a/libs/ui/src/lib/portfolio-proportion-chart/portfolio-proportion-chart.component.ts
+++ b/libs/ui/src/lib/portfolio-proportion-chart/portfolio-proportion-chart.component.ts
@@ -205,7 +205,7 @@ export class PortfolioProportionChartComponent
chartDataSorted.forEach(([, item]) => {
let lightnessRatio = 0.2;
- Object.keys(item.subCategory).forEach((subCategory) => {
+ Object.keys(item.subCategory ?? {}).forEach((subCategory) => {
backgroundColorSubCategory.push(
Color(item.color).lighten(lightnessRatio).hex()
);