Skip to content

Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍

Feature/extend accounts endpoint by allocations (#5358)

Attila Cseh2b8a7de950d9
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d71772e8f7..af2c5fc17d 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 f40ed57e55..1d010bcf76 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,