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,