Bugfix/support multiple accounts with the same name (#623)

* Support multiple accounts with the same name

* Update changelog
pull/622/head
Thomas Kaul 3 years ago committed by GitHub
parent a83441b3ba
commit b2b3fde80e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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/), 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). 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 ## 1.101.0 - 08.01.2022
### Added ### Added

@ -107,7 +107,7 @@ export class PortfolioService {
account.currency, account.currency,
userCurrency userCurrency
), ),
value: details.accounts[account.name]?.current ?? 0 value: details.accounts[account.id]?.current ?? 0
}; };
delete result.Order; delete result.Order;
@ -1091,10 +1091,11 @@ export class PortfolioService {
account.currency, account.currency,
userCurrency userCurrency
); );
accounts[account.name] = { accounts[account.id] = {
balance: convertedBalance, balance: convertedBalance,
currency: account.currency, currency: account.currency,
current: convertedBalance, current: convertedBalance,
name: account.name,
original: convertedBalance original: convertedBalance
}; };
@ -1108,16 +1109,17 @@ export class PortfolioService {
originalValueOfSymbol *= -1; originalValueOfSymbol *= -1;
} }
if (accounts[order.Account?.name || UNKNOWN_KEY]?.current) { if (accounts[order.Account?.id || UNKNOWN_KEY]?.current) {
accounts[order.Account?.name || UNKNOWN_KEY].current += accounts[order.Account?.id || UNKNOWN_KEY].current +=
currentValueOfSymbol; currentValueOfSymbol;
accounts[order.Account?.name || UNKNOWN_KEY].original += accounts[order.Account?.id || UNKNOWN_KEY].original +=
originalValueOfSymbol; originalValueOfSymbol;
} else { } else {
accounts[order.Account?.name || UNKNOWN_KEY] = { accounts[order.Account?.id || UNKNOWN_KEY] = {
balance: 0, balance: 0,
currency: order.Account?.currency, currency: order.Account?.currency,
current: currentValueOfSymbol, current: currentValueOfSymbol,
name: account.name,
original: originalValueOfSymbol original: originalValueOfSymbol
}; };
} }

@ -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.portfolioDetails.accounts
)) { )) {
this.accounts[name] = { this.accounts[id] = {
name, name,
value: aPeriod === 'original' ? original : current value: aPeriod === 'original' ? original : current
}; };

@ -2,10 +2,11 @@ import { PortfolioPosition } from '@ghostfolio/common/interfaces';
export interface PortfolioDetails { export interface PortfolioDetails {
accounts: { accounts: {
[name: string]: { [id: string]: {
balance: number; balance: number;
currency: string; currency: string;
current: number; current: number;
name: string;
original: number; original: number;
}; };
}; };

Loading…
Cancel
Save