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

* Support multiple accounts with the same name

* Update changelog
pull/622/head
Thomas Kaul 2 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/),
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
### Added

@ -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
};
}

@ -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
};

@ -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;
};
};

Loading…
Cancel
Save