From 2b8a7de950d9881e0703ac17e0a26835b0299c87 Mon Sep 17 00:00:00 2001 From: Attila Cseh <77381875+csehatt741@users.noreply.github.com> Date: Thu, 14 Aug 2025 20:49:45 +0200 Subject: [PATCH] Feature/extend accounts endpoint by allocations (#5358) * Extend accounts endpoint by allocations * Update changelog --- CHANGELOG.md | 1 + apps/api/src/app/portfolio/portfolio.service.ts | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d71772e8f..af2c5fc17 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Moved the chart of the account detail dialog from experimental to general availability - Improved the dynamic numerical precision for various values in the account detail dialog - Improved the usability of the _Cancel_ / _Close_ and _Save_ buttons in various dialogs +- Extended the accounts endpoint by allocations - Extended the accounts endpoint by dividend and interest - Refactored the portfolio performance component to standalone - Improved the language localization for Portuguese (`pt`) diff --git a/apps/api/src/app/portfolio/portfolio.service.ts b/apps/api/src/app/portfolio/portfolio.service.ts index f40ed57e5..1d010bcf7 100644 --- a/apps/api/src/app/portfolio/portfolio.service.ts +++ b/apps/api/src/app/portfolio/portfolio.service.ts @@ -227,7 +227,7 @@ export class PortfolioService { interestInBaseCurrency, transactionCount, valueInBaseCurrency, - allocationInPercentage: null, // TODO + allocationInPercentage: 0, balanceInBaseCurrency: this.exchangeRateDataService.toCurrency( account.balance, account.currency, @@ -299,6 +299,15 @@ export class PortfolioService { transactionCount += account.transactionCount; } + for (const account of accounts) { + account.allocationInPercentage = + totalValueInBaseCurrency.toNumber() > Number.EPSILON + ? Big(account.valueInBaseCurrency) + .div(totalValueInBaseCurrency) + .toNumber() + : 0; + } + return { accounts, transactionCount,