Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript đ€
TypeScript angularetffinancefintechghostfoliohacktoberfestinvestingnestjsosspersonal-financeportfolioprismasoftwarestocktrackertradingtypescriptwealth-managementweb
Feature/add percentage visualization of the current filter (#1268)
Thomas Kauld4c3a9d1e84a
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 2d60fa9063..cd7d6bf46c 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0### Added- Added `NODE_ENV: production` to the `docker-compose` files (`docker-compose.yml` and `docker-compose.build.yml`)+- Visualized the percentage of the active filter on the allocations page### Changeddiff --git a/apps/api/src/app/portfolio/portfolio.controller.ts b/apps/api/src/app/portfolio/portfolio.controller.tsindex fc443ab936..86bc8c2fa2 100644--- a/apps/api/src/app/portfolio/portfolio.controller.ts+++ b/apps/api/src/app/portfolio/portfolio.controller.ts@@ -168,13 +168,19 @@ export class PortfolioController {})];- const { accounts, holdings, hasErrors } =- await this.portfolioService.getDetails(- impersonationId,- this.request.user.id,- range,- filters- );+ const {+ accounts,+ filteredValueInBaseCurrency,+ filteredValueInPercentage,+ hasErrors,+ holdings,+ totalValueInBaseCurrency+ } = await this.portfolioService.getDetails(+ impersonationId,+ this.request.user.id,+ range,+ filters+ );if (hasErrors || hasNotDefinedValuesInObject(holdings)) {hasError = true;@@ -234,8 +240,11 @@ export class PortfolioController {return {accounts,+ filteredValueInBaseCurrency,+ filteredValueInPercentage,hasError,- holdings+ holdings,+ totalValueInBaseCurrency};}diff --git a/apps/api/src/app/portfolio/portfolio.service.ts b/apps/api/src/app/portfolio/portfolio.service.tsindex d8aed4c176..8868245c42 100644--- a/apps/api/src/app/portfolio/portfolio.service.ts+++ b/apps/api/src/app/portfolio/portfolio.service.ts@@ -474,12 +474,21 @@ export class PortfolioService {});const holdings: PortfolioDetails['holdings'] = {};- const totalInvestment = currentPositions.totalInvestment.plus(- cashDetails.balanceInBaseCurrency- );- const totalValue = currentPositions.currentValue.plus(+ const totalInvestmentInBaseCurrency = currentPositions.totalInvestment.plus(cashDetails.balanceInBaseCurrency);+ let filteredValueInBaseCurrency = currentPositions.currentValue;++ if (+ aFilters?.length === 0 ||+ (aFilters?.length === 1 &&+ aFilters[0].type === 'ASSET_CLASS' &&+ aFilters[0].id === 'CASH')+ ) {+ filteredValueInBaseCurrency = filteredValueInBaseCurrency.plus(+ cashDetails.balanceInBaseCurrency+ );+ }const dataGatheringItems = currentPositions.positions.map((position) => {return {@@ -540,10 +549,12 @@ export class PortfolioService {holdings[item.symbol] = {markets,- allocationCurrent: totalValue.eq(0)+ allocationCurrent: filteredValueInBaseCurrency.eq(0)? 0- : value.div(totalValue).toNumber(),- allocationInvestment: item.investment.div(totalInvestment).toNumber(),+ : value.div(filteredValueInBaseCurrency).toNumber(),+ allocationInvestment: item.investment+ .div(totalInvestmentInBaseCurrency)+ .toNumber(),assetClass: symbolProfile.assetClass,assetSubClass: symbolProfile.assetSubClass,countries: symbolProfile.countries,@@ -577,8 +588,8 @@ export class PortfolioService {cashDetails,emergencyFund,userCurrency,- investment: totalInvestment,- value: totalValue+ investment: totalInvestmentInBaseCurrency,+ value: filteredValueInBaseCurrency});for (const symbol of Object.keys(cashPositions)) {@@ -594,7 +605,18 @@ export class PortfolioService {filters: aFilters});- return { accounts, holdings, hasErrors: currentPositions.hasErrors };+ const summary = await this.getSummary(aImpersonationId);++ return {+ accounts,+ holdings,+ filteredValueInBaseCurrency: filteredValueInBaseCurrency.toNumber(),+ filteredValueInPercentage: summary.netWorth+ ? filteredValueInBaseCurrency.div(summary.netWorth).toNumber()+ : 0,+ hasErrors: currentPositions.hasErrors,+ totalValueInBaseCurrency: summary.netWorth+ };}public async getPosition(diff --git a/apps/api/src/interceptors/redact-values-in-response.interceptor.ts b/apps/api/src/interceptors/redact-values-in-response.interceptor.tsindex b5889328dd..4a9c5bef2c 100644--- a/apps/api/src/interceptors/redact-values-in-response.interceptor.ts+++ b/apps/api/src/interceptors/redact-values-in-response.interceptor.ts@@ -41,6 +41,14 @@ export class RedactValuesInResponseInterceptor<T>return activity;});}++ if (data.filteredValueInBaseCurrency) {+ data.filteredValueInBaseCurrency = null;+ }++ if (data.totalValueInBaseCurrency) {+ data.totalValueInBaseCurrency = null;+ }}return data;diff --git a/apps/client/src/app/pages/portfolio/allocations/allocations-page.html b/apps/client/src/app/pages/portfolio/allocations/allocations-page.htmlindex 51aa49ae2c..4a030c8a0a 100644--- a/apps/client/src/app/pages/portfolio/allocations/allocations-page.html+++ b/apps/client/src/app/pages/portfolio/allocations/allocations-page.html@@ -10,6 +10,22 @@></gf-activities-filter></div></div>+ <div class="row">+ <div class="col">+ <mat-card class="mb-3">+ <mat-card-header>+ <mat-card-title i18n>Proportion of Net Worth</mat-card-title>+ </mat-card-header>+ <mat-card-content>+ <mat-progress-bar+ mode="determinate"+ [title]="(portfolioDetails?.filteredValueInPercentage * 100).toFixed(2) + '%'"+ [value]="portfolioDetails?.filteredValueInPercentage * 100"+ ></mat-progress-bar>+ </mat-card-content>+ </mat-card>+ </div>+ </div><div class="proportion-charts row"><div class="col-md-4"><mat-card class="mb-3">diff --git a/apps/client/src/app/pages/portfolio/allocations/allocations-page.module.ts b/apps/client/src/app/pages/portfolio/allocations/allocations-page.module.tsindex 65594048b0..172db1b25a 100644--- a/apps/client/src/app/pages/portfolio/allocations/allocations-page.module.ts+++ b/apps/client/src/app/pages/portfolio/allocations/allocations-page.module.ts@@ -1,6 +1,7 @@import { CommonModule } from '@angular/common';import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';import { MatCardModule } from '@angular/material/card';+import { MatProgressBarModule } from '@angular/material/progress-bar';import { GfToggleModule } from '@ghostfolio/client/components/toggle/toggle.module';import { GfWorldMapChartModule } from '@ghostfolio/client/components/world-map-chart/world-map-chart.module';import { GfActivitiesFilterModule } from '@ghostfolio/ui/activities-filter/activities-filter.module';@@ -22,7 +23,8 @@ import { AllocationsPageComponent } from './allocations-page.component';GfToggleModule,GfWorldMapChartModule,GfValueModule,- MatCardModule+ MatCardModule,+ MatProgressBarModule],schemas: [CUSTOM_ELEMENTS_SCHEMA]})diff --git a/apps/client/src/app/pages/portfolio/allocations/allocations-page.scss b/apps/client/src/app/pages/portfolio/allocations/allocations-page.scssindex 0a12304c1b..ca8b56096e 100644--- a/apps/client/src/app/pages/portfolio/allocations/allocations-page.scss+++ b/apps/client/src/app/pages/portfolio/allocations/allocations-page.scss@@ -28,4 +28,33 @@}}}++ .mat-progress-bar {+ border-radius: 0.25rem;+ height: 0.5rem;++ ::ng-deep {+ .mat-progress-bar-background {+ fill: rgb(var(--palette-background-unselected-chip));+ }++ .mat-progress-bar-buffer {+ background-color: rgb(var(--palette-background-unselected-chip));+ }+ }+ }+}++:host-context(.is-dark-theme) {+ .mat-progress-bar {+ ::ng-deep {+ .mat-progress-bar-background {+ fill: rgb(var(--palette-background-unselected-chip-dark));+ }++ .mat-progress-bar-buffer {+ background-color: rgb(var(--palette-background-unselected-chip-dark));+ }+ }+ }}diff --git a/apps/client/src/locales/messages.de.xlf b/apps/client/src/locales/messages.de.xlfindex 8f17dc3e52..9289a3a754 100644--- a/apps/client/src/locales/messages.de.xlf+++ b/apps/client/src/locales/messages.de.xlf@@ -1031,7 +1031,7 @@</trans-unit><trans-unit id="67251f04518ae452230c68a748b3fa2838b4db74" datatype="html"><source>Net Worth</source>- <target state="translated">Reinvermögen</target>+ <target state="translated">Gesamtvermögen</target><context-group purpose="location"><context context-type="sourcefile">apps/client/src/app/components/portfolio-summary/portfolio-summary.component.html</context><context context-type="linenumber">179</context>@@ -1618,7 +1618,7 @@<target state="translated">Nach Konto</target><context-group purpose="location"><context context-type="sourcefile">apps/client/src/app/pages/portfolio/allocations/allocations-page.html</context>- <context context-type="linenumber">17</context>+ <context context-type="linenumber">33</context></context-group></trans-unit><trans-unit id="b79f5520c0cb9a00bd589e8a4c86ffcf5ae439d7" datatype="html">@@ -1626,7 +1626,7 @@<target state="translated">Nach WÀhrung</target><context-group purpose="location"><context context-type="sourcefile">apps/client/src/app/pages/portfolio/allocations/allocations-page.html</context>- <context context-type="linenumber">42</context>+ <context context-type="linenumber">58</context></context-group></trans-unit><trans-unit id="8288ff761f2d259625d2e5a3d96db727926d9cd4" datatype="html">@@ -1634,7 +1634,7 @@<target state="translated">Nach Asset Class</target><context-group purpose="location"><context context-type="sourcefile">apps/client/src/app/pages/portfolio/allocations/allocations-page.html</context>- <context context-type="linenumber">70</context>+ <context context-type="linenumber">86</context></context-group></trans-unit><trans-unit id="b64539bb7815eb3275b55ad723d3897fc6ba8d23" datatype="html">@@ -1642,7 +1642,7 @@<target state="translated">Nach Position</target><context-group purpose="location"><context context-type="sourcefile">apps/client/src/app/pages/portfolio/allocations/allocations-page.html</context>- <context context-type="linenumber">98</context>+ <context context-type="linenumber">114</context></context-group></trans-unit><trans-unit id="9f86714c9a6b74e13c96ab02102ce40c34fe13b9" datatype="html">@@ -1650,7 +1650,7 @@<target state="translated">Nach Sektor</target><context-group purpose="location"><context context-type="sourcefile">apps/client/src/app/pages/portfolio/allocations/allocations-page.html</context>- <context context-type="linenumber">126</context>+ <context context-type="linenumber">142</context></context-group></trans-unit><trans-unit id="7017e0e26b53ef322c3e3bbf95f06a85487a12b2" datatype="html">@@ -1658,7 +1658,7 @@<target state="translated">Nach Kontinent</target><context-group purpose="location"><context context-type="sourcefile">apps/client/src/app/pages/portfolio/allocations/allocations-page.html</context>- <context context-type="linenumber">155</context>+ <context context-type="linenumber">171</context></context-group></trans-unit><trans-unit id="f27e9dd8de80176286e02312e694cb8d1e485a5d" datatype="html">@@ -1666,7 +1666,7 @@<target state="translated">Nach Land</target><context-group purpose="location"><context context-type="sourcefile">apps/client/src/app/pages/portfolio/allocations/allocations-page.html</context>- <context context-type="linenumber">183</context>+ <context context-type="linenumber">199</context></context-group></trans-unit><trans-unit id="85780db87ac6c9f202615ac63754551c061e7236" datatype="html">@@ -1674,7 +1674,7 @@<target state="translated">Regionen</target><context-group purpose="location"><context context-type="sourcefile">apps/client/src/app/pages/portfolio/allocations/allocations-page.html</context>- <context context-type="linenumber">214</context>+ <context context-type="linenumber">230</context></context-group><context-group purpose="location"><context context-type="sourcefile">apps/client/src/app/pages/public/public-page.html</context>@@ -2418,7 +2418,7 @@<target state="translated">Entwickelte LÀnder</target><context-group purpose="location"><context context-type="sourcefile">apps/client/src/app/pages/portfolio/allocations/allocations-page.html</context>- <context context-type="linenumber">240</context>+ <context context-type="linenumber">256</context></context-group><context-group purpose="location"><context context-type="sourcefile">apps/client/src/app/pages/public/public-page.html</context>@@ -2430,7 +2430,7 @@<target state="translated">SchwellenlÀnder</target><context-group purpose="location"><context context-type="sourcefile">apps/client/src/app/pages/portfolio/allocations/allocations-page.html</context>- <context context-type="linenumber">249</context>+ <context context-type="linenumber">265</context></context-group><context-group purpose="location"><context context-type="sourcefile">apps/client/src/app/pages/public/public-page.html</context>@@ -2442,7 +2442,7 @@<target state="translated">Andere LÀnder</target><context-group purpose="location"><context context-type="sourcefile">apps/client/src/app/pages/portfolio/allocations/allocations-page.html</context>- <context context-type="linenumber">258</context>+ <context context-type="linenumber">274</context></context-group><context-group purpose="location"><context context-type="sourcefile">apps/client/src/app/pages/public/public-page.html</context>@@ -2637,6 +2637,14 @@<context context-type="linenumber">120</context></context-group></trans-unit>+ <trans-unit id="4210837540bca56dca96fcc451518659d06ad02a" datatype="html">+ <source>Proportion of Net Worth</source>+ <target state="translated">Anteil am Gesamtvermögen</target>+ <context-group purpose="location">+ <context context-type="sourcefile">apps/client/src/app/pages/portfolio/allocations/allocations-page.html</context>+ <context context-type="linenumber">17</context>+ </context-group>+ </trans-unit></body></file></xliff>diff --git a/apps/client/src/locales/messages.it.xlf b/apps/client/src/locales/messages.it.xlfindex e868bb4c00..01697c2ad5 100644--- a/apps/client/src/locales/messages.it.xlf+++ b/apps/client/src/locales/messages.it.xlf@@ -1453,56 +1453,56 @@<source>By Account</source><context-group purpose="location"><context context-type="sourcefile">apps/client/src/app/pages/portfolio/allocations/allocations-page.html</context>- <context context-type="linenumber">17</context>+ <context context-type="linenumber">33</context></context-group></trans-unit><trans-unit id="b79f5520c0cb9a00bd589e8a4c86ffcf5ae439d7" datatype="html"><source>By Currency</source><context-group purpose="location"><context context-type="sourcefile">apps/client/src/app/pages/portfolio/allocations/allocations-page.html</context>- <context context-type="linenumber">42</context>+ <context context-type="linenumber">58</context></context-group></trans-unit><trans-unit id="8288ff761f2d259625d2e5a3d96db727926d9cd4" datatype="html"><source>By Asset Class</source><context-group purpose="location"><context context-type="sourcefile">apps/client/src/app/pages/portfolio/allocations/allocations-page.html</context>- <context context-type="linenumber">70</context>+ <context context-type="linenumber">86</context></context-group></trans-unit><trans-unit id="b64539bb7815eb3275b55ad723d3897fc6ba8d23" datatype="html"><source>By Holding</source><context-group purpose="location"><context context-type="sourcefile">apps/client/src/app/pages/portfolio/allocations/allocations-page.html</context>- <context context-type="linenumber">98</context>+ <context context-type="linenumber">114</context></context-group></trans-unit><trans-unit id="9f86714c9a6b74e13c96ab02102ce40c34fe13b9" datatype="html"><source>By Sector</source><context-group purpose="location"><context context-type="sourcefile">apps/client/src/app/pages/portfolio/allocations/allocations-page.html</context>- <context context-type="linenumber">126</context>+ <context context-type="linenumber">142</context></context-group></trans-unit><trans-unit id="7017e0e26b53ef322c3e3bbf95f06a85487a12b2" datatype="html"><source>By Continent</source><context-group purpose="location"><context context-type="sourcefile">apps/client/src/app/pages/portfolio/allocations/allocations-page.html</context>- <context context-type="linenumber">155</context>+ <context context-type="linenumber">171</context></context-group></trans-unit><trans-unit id="f27e9dd8de80176286e02312e694cb8d1e485a5d" datatype="html"><source>By Country</source><context-group purpose="location"><context context-type="sourcefile">apps/client/src/app/pages/portfolio/allocations/allocations-page.html</context>- <context context-type="linenumber">183</context>+ <context context-type="linenumber">199</context></context-group></trans-unit><trans-unit id="85780db87ac6c9f202615ac63754551c061e7236" datatype="html"><source>Regions</source><context-group purpose="location"><context context-type="sourcefile">apps/client/src/app/pages/portfolio/allocations/allocations-page.html</context>- <context context-type="linenumber">214</context>+ <context context-type="linenumber">230</context></context-group><context-group purpose="location"><context context-type="sourcefile">apps/client/src/app/pages/public/public-page.html</context>@@ -2104,7 +2104,7 @@<source>Developed Markets</source><context-group purpose="location"><context context-type="sourcefile">apps/client/src/app/pages/portfolio/allocations/allocations-page.html</context>- <context context-type="linenumber">240</context>+ <context context-type="linenumber">256</context></context-group><context-group purpose="location"><context context-type="sourcefile">apps/client/src/app/pages/public/public-page.html</context>@@ -2144,7 +2144,7 @@<source>Other Markets</source><context-group purpose="location"><context context-type="sourcefile">apps/client/src/app/pages/portfolio/allocations/allocations-page.html</context>- <context context-type="linenumber">258</context>+ <context context-type="linenumber">274</context></context-group><context-group purpose="location"><context context-type="sourcefile">apps/client/src/app/pages/public/public-page.html</context>@@ -2155,7 +2155,7 @@<source>Emerging Markets</source><context-group purpose="location"><context context-type="sourcefile">apps/client/src/app/pages/portfolio/allocations/allocations-page.html</context>- <context context-type="linenumber">249</context>+ <context context-type="linenumber">265</context></context-group><context-group purpose="location"><context context-type="sourcefile">apps/client/src/app/pages/public/public-page.html</context>@@ -2356,6 +2356,13 @@<context context-type="linenumber">14</context></context-group></trans-unit>+ <trans-unit id="4210837540bca56dca96fcc451518659d06ad02a" datatype="html">+ <source>Proportion of Net Worth</source>+ <context-group purpose="location">+ <context context-type="sourcefile">apps/client/src/app/pages/portfolio/allocations/allocations-page.html</context>+ <context context-type="linenumber">17</context>+ </context-group>+ </trans-unit></body></file></xliff>diff --git a/apps/client/src/locales/messages.xlf b/apps/client/src/locales/messages.xlfindex 548e017d34..670583b595 100644--- a/apps/client/src/locales/messages.xlf+++ b/apps/client/src/locales/messages.xlf@@ -1453,56 +1453,56 @@<source>By Account</source><context-group purpose="location"><context context-type="sourcefile">apps/client/src/app/pages/portfolio/allocations/allocations-page.html</context>- <context context-type="linenumber">17</context>+ <context context-type="linenumber">33</context></context-group></trans-unit><trans-unit id="b79f5520c0cb9a00bd589e8a4c86ffcf5ae439d7" datatype="html"><source>By Currency</source><context-group purpose="location"><context context-type="sourcefile">apps/client/src/app/pages/portfolio/allocations/allocations-page.html</context>- <context context-type="linenumber">42</context>+ <context context-type="linenumber">58</context></context-group></trans-unit><trans-unit id="8288ff761f2d259625d2e5a3d96db727926d9cd4" datatype="html"><source>By Asset Class</source><context-group purpose="location"><context context-type="sourcefile">apps/client/src/app/pages/portfolio/allocations/allocations-page.html</context>- <context context-type="linenumber">70</context>+ <context context-type="linenumber">86</context></context-group></trans-unit><trans-unit id="b64539bb7815eb3275b55ad723d3897fc6ba8d23" datatype="html"><source>By Holding</source><context-group purpose="location"><context context-type="sourcefile">apps/client/src/app/pages/portfolio/allocations/allocations-page.html</context>- <context context-type="linenumber">98</context>+ <context context-type="linenumber">114</context></context-group></trans-unit><trans-unit id="9f86714c9a6b74e13c96ab02102ce40c34fe13b9" datatype="html"><source>By Sector</source><context-group purpose="location"><context context-type="sourcefile">apps/client/src/app/pages/portfolio/allocations/allocations-page.html</context>- <context context-type="linenumber">126</context>+ <context context-type="linenumber">142</context></context-group></trans-unit><trans-unit id="7017e0e26b53ef322c3e3bbf95f06a85487a12b2" datatype="html"><source>By Continent</source><context-group purpose="location"><context context-type="sourcefile">apps/client/src/app/pages/portfolio/allocations/allocations-page.html</context>- <context context-type="linenumber">155</context>+ <context context-type="linenumber">171</context></context-group></trans-unit><trans-unit id="f27e9dd8de80176286e02312e694cb8d1e485a5d" datatype="html"><source>By Country</source><context-group purpose="location"><context context-type="sourcefile">apps/client/src/app/pages/portfolio/allocations/allocations-page.html</context>- <context context-type="linenumber">183</context>+ <context context-type="linenumber">199</context></context-group></trans-unit><trans-unit id="85780db87ac6c9f202615ac63754551c061e7236" datatype="html"><source>Regions</source><context-group purpose="location"><context context-type="sourcefile">apps/client/src/app/pages/portfolio/allocations/allocations-page.html</context>- <context context-type="linenumber">214</context>+ <context context-type="linenumber">230</context></context-group><context-group purpose="location"><context context-type="sourcefile">apps/client/src/app/pages/public/public-page.html</context>@@ -2104,7 +2104,7 @@<source>Developed Markets</source><context-group purpose="location"><context context-type="sourcefile">apps/client/src/app/pages/portfolio/allocations/allocations-page.html</context>- <context context-type="linenumber">240</context>+ <context context-type="linenumber">256</context></context-group><context-group purpose="location"><context context-type="sourcefile">apps/client/src/app/pages/public/public-page.html</context>@@ -2144,7 +2144,7 @@<source>Other Markets</source><context-group purpose="location"><context context-type="sourcefile">apps/client/src/app/pages/portfolio/allocations/allocations-page.html</context>- <context context-type="linenumber">258</context>+ <context context-type="linenumber">274</context></context-group><context-group purpose="location"><context context-type="sourcefile">apps/client/src/app/pages/public/public-page.html</context>@@ -2155,7 +2155,7 @@<source>Emerging Markets</source><context-group purpose="location"><context context-type="sourcefile">apps/client/src/app/pages/portfolio/allocations/allocations-page.html</context>- <context context-type="linenumber">249</context>+ <context context-type="linenumber">265</context></context-group><context-group purpose="location"><context context-type="sourcefile">apps/client/src/app/pages/public/public-page.html</context>@@ -2356,6 +2356,13 @@<context context-type="linenumber">14</context></context-group></trans-unit>+ <trans-unit id="4210837540bca56dca96fcc451518659d06ad02a" datatype="html">+ <source>Proportion of Net Worth</source>+ <context-group purpose="location">+ <context context-type="sourcefile">apps/client/src/app/pages/portfolio/allocations/allocations-page.html</context>+ <context context-type="linenumber">17</context>+ </context-group>+ </trans-unit></body></file></xliff>\ No newline at end of filediff --git a/libs/common/src/lib/interfaces/portfolio-details.interface.ts b/libs/common/src/lib/interfaces/portfolio-details.interface.tsindex 17430438bf..cffa3ac0d4 100644--- a/libs/common/src/lib/interfaces/portfolio-details.interface.ts+++ b/libs/common/src/lib/interfaces/portfolio-details.interface.ts@@ -10,5 +10,8 @@ export interface PortfolioDetails {original: number;};};+ filteredValueInBaseCurrency?: number;+ filteredValueInPercentage: number;holdings: { [symbol: string]: PortfolioPosition };+ totalValueInBaseCurrency?: number;}