Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍
TypeScript angularetffinancefintechghostfoliohacktoberfestinvestingnestjsosspersonal-financeportfolioprismasoftwarestocktrackertradingtypescriptwealth-managementweb
Bugfix/support multiple accounts with the same name (#623)
Thomas Kaulb2b3fde80e20
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 6983303d22..2cceba33c9 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).+## Unreleased++### Fixed++- Fixed the support for multiple accounts with the same name+## 1.101.0 - 08.01.2022### Addeddiff --git a/apps/api/src/app/portfolio/portfolio.service.ts b/apps/api/src/app/portfolio/portfolio.service.tsindex 1902fd137a..9ed19810f3 100644--- a/apps/api/src/app/portfolio/portfolio.service.ts+++ b/apps/api/src/app/portfolio/portfolio.service.ts@@ -107,7 +107,7 @@ export class PortfolioService {account.currency,userCurrency),- value: details.accounts[account.name]?.current ?? 0+ value: details.accounts[account.id]?.current ?? 0};delete result.Order;@@ -1091,10 +1091,11 @@ export class PortfolioService {account.currency,userCurrency);- accounts[account.name] = {+ accounts[account.id] = {balance: convertedBalance,currency: account.currency,current: convertedBalance,+ name: account.name,original: convertedBalance};@@ -1108,16 +1109,17 @@ export class PortfolioService {originalValueOfSymbol *= -1;}- if (accounts[order.Account?.name || UNKNOWN_KEY]?.current) {- accounts[order.Account?.name || UNKNOWN_KEY].current +=+ if (accounts[order.Account?.id || UNKNOWN_KEY]?.current) {+ accounts[order.Account?.id || UNKNOWN_KEY].current +=currentValueOfSymbol;- accounts[order.Account?.name || UNKNOWN_KEY].original +=+ accounts[order.Account?.id || UNKNOWN_KEY].original +=originalValueOfSymbol;} else {- accounts[order.Account?.name || UNKNOWN_KEY] = {+ accounts[order.Account?.id || UNKNOWN_KEY] = {balance: 0,currency: order.Account?.currency,current: currentValueOfSymbol,+ name: account.name,original: originalValueOfSymbol};}diff --git a/apps/client/src/app/pages/portfolio/allocations/allocations-page.component.ts b/apps/client/src/app/pages/portfolio/allocations/allocations-page.component.tsindex 5ab8ba1b55..c19af7fb45 100644--- a/apps/client/src/app/pages/portfolio/allocations/allocations-page.component.ts+++ b/apps/client/src/app/pages/portfolio/allocations/allocations-page.component.ts@@ -162,10 +162,10 @@ export class AllocationsPageComponent implements OnDestroy, OnInit {}};- for (const [name, { current, original }] of Object.entries(+ for (const [id, { current, name, original }] of Object.entries(this.portfolioDetails.accounts)) {- this.accounts[name] = {+ this.accounts[id] = {name,value: aPeriod === 'original' ? original : current};diff --git a/libs/common/src/lib/interfaces/portfolio-details.interface.ts b/libs/common/src/lib/interfaces/portfolio-details.interface.tsindex 2cbf1c6fa7..17430438bf 100644--- a/libs/common/src/lib/interfaces/portfolio-details.interface.ts+++ b/libs/common/src/lib/interfaces/portfolio-details.interface.ts@@ -2,10 +2,11 @@ import { PortfolioPosition } from '@ghostfolio/common/interfaces';export interface PortfolioDetails {accounts: {- [name: string]: {+ [id: string]: {balance: number;currency: string;current: number;+ name: string;original: number;};};