diff --git a/apps/api/src/app/portfolio/portfolio.controller.ts b/apps/api/src/app/portfolio/portfolio.controller.ts index 0df8051c2..79d0f8259 100644 --- a/apps/api/src/app/portfolio/portfolio.controller.ts +++ b/apps/api/src/app/portfolio/portfolio.controller.ts @@ -136,8 +136,8 @@ export class PortfolioController { portfolioPosition.value / totalValue; } - for (const [name, { current }] of Object.entries(accounts)) { - accounts[name].current = current / totalValue; + for (const [name, { valueInBaseCurrency }] of Object.entries(accounts)) { + accounts[name].valueInBaseCurrency = valueInBaseCurrency / totalValue; } } diff --git a/apps/api/src/app/portfolio/portfolio.service.ts b/apps/api/src/app/portfolio/portfolio.service.ts index d94c976ce..6db73cebf 100644 --- a/apps/api/src/app/portfolio/portfolio.service.ts +++ b/apps/api/src/app/portfolio/portfolio.service.ts @@ -146,7 +146,8 @@ export class PortfolioService { } } - const valueInBaseCurrency = details.accounts[account.id]?.current ?? 0; + const valueInBaseCurrency = + details.accounts[account.id]?.valueInBaseCurrency ?? 0; const result = { ...account, @@ -615,8 +616,8 @@ export class PortfolioService { accounts[UNKNOWN_KEY] = { balance: 0, currency: userCurrency, - current: emergencyFundInCash, - name: UNKNOWN_KEY + name: UNKNOWN_KEY, + valueInBaseCurrency: emergencyFundInCash }; holdings[userCurrency] = { @@ -1758,12 +1759,12 @@ export class PortfolioService { accounts[account.id] = { balance: account.balance, currency: account.currency, - current: this.exchangeRateDataService.toCurrency( + name: account.name, + valueInBaseCurrency: this.exchangeRateDataService.toCurrency( account.balance, account.currency, userCurrency - ), - name: account.name + ) }; for (const order of ordersByAccount) { @@ -1777,15 +1778,15 @@ export class PortfolioService { currentValueOfSymbolInBaseCurrency *= -1; } - if (accounts[order.Account?.id || UNKNOWN_KEY]?.current) { - accounts[order.Account?.id || UNKNOWN_KEY].current += + if (accounts[order.Account?.id || UNKNOWN_KEY]?.valueInBaseCurrency) { + accounts[order.Account?.id || UNKNOWN_KEY].valueInBaseCurrency += currentValueOfSymbolInBaseCurrency; } else { accounts[order.Account?.id || UNKNOWN_KEY] = { balance: 0, currency: order.Account?.currency, - current: currentValueOfSymbolInBaseCurrency, - name: account.name + name: account.name, + valueInBaseCurrency: currentValueOfSymbolInBaseCurrency }; } } diff --git a/apps/api/src/models/rules/account-cluster-risk/current-investment.ts b/apps/api/src/models/rules/account-cluster-risk/current-investment.ts index 7c1059ac1..d0cdbb58c 100644 --- a/apps/api/src/models/rules/account-cluster-risk/current-investment.ts +++ b/apps/api/src/models/rules/account-cluster-risk/current-investment.ts @@ -28,7 +28,7 @@ export class AccountClusterRiskCurrentInvestment extends Rule { for (const [accountId, account] of Object.entries(this.accounts)) { accounts[accountId] = { name: account.name, - investment: account.current + investment: account.valueInBaseCurrency }; } 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.ts index 7d541553f..e7e771f36 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 @@ -249,13 +249,13 @@ export class AllocationsPageComponent implements OnDestroy, OnInit { public initializeAnalysisData() { this.initialize(); - for (const [id, { current, name }] of Object.entries( + for (const [id, { name, valueInBaseCurrency }] of Object.entries( this.portfolioDetails.accounts )) { this.accounts[id] = { id, name, - value: current + value: valueInBaseCurrency }; } diff --git a/libs/common/src/lib/interfaces/portfolio-details.interface.ts b/libs/common/src/lib/interfaces/portfolio-details.interface.ts index 61ec1939f..56fadf9c5 100644 --- a/libs/common/src/lib/interfaces/portfolio-details.interface.ts +++ b/libs/common/src/lib/interfaces/portfolio-details.interface.ts @@ -8,8 +8,8 @@ export interface PortfolioDetails { [id: string]: { balance: number; currency: string; - current: number; name: string; + valueInBaseCurrency: number; }; }; filteredValueInBaseCurrency?: number;