Skip to content

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

Feature/add allocations percentage to accounts table component (#4720)

Joseph Baoadc00694cf36
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3a82ded75a..1869102329 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## Unreleased
+### Added
+
+- Added the allocation column to the accounts table component of the holding detail dialog
+
### Changed
- Restructured the response of the portfolio report endpoint (_X-ray_)
diff --git a/apps/api/src/app/portfolio/portfolio.service.ts b/apps/api/src/app/portfolio/portfolio.service.ts
index c5b9c21482..83653dd9fb 100644
--- a/apps/api/src/app/portfolio/portfolio.service.ts
+++ b/apps/api/src/app/portfolio/portfolio.service.ts
@@ -191,6 +191,7 @@ export class PortfolioService {
...account,
transactionCount,
valueInBaseCurrency,
+ allocationInPercentage: null, // TODO
balanceInBaseCurrency: this.exchangeRateDataService.toCurrency(
account.balance,
account.currency,
diff --git a/apps/client/src/app/components/accounts-table/accounts-table.component.html b/apps/client/src/app/components/accounts-table/accounts-table.component.html
index 7e2ac92db0..609c76ee17 100644
--- a/apps/client/src/app/components/accounts-table/accounts-table.component.html
+++ b/apps/client/src/app/components/accounts-table/accounts-table.component.html
@@ -231,6 +231,35 @@
</td>
</ng-container>
+ <ng-container matColumnDef="allocation">
+ <th
+ *matHeaderCellDef
+ class="d-none d-lg-table-cell justify-content-end px-1"
+ mat-header-cell
+ mat-sort-header
+ >
+ <ng-container i18n>Allocation</ng-container>
+ </th>
+ <td
+ *matCellDef="let element"
+ class="d-none d-lg-table-cell px-1 text-right"
+ mat-cell
+ >
+ <gf-value
+ class="d-inline-block justify-content-end"
+ [isPercent]="true"
+ [locale]="locale"
+ [precision]="2"
+ [value]="element.allocationInPercentage"
+ />
+ </td>
+ <td
+ *matFooterCellDef
+ class="d-none d-lg-table-cell px-1"
+ mat-footer-cell
+ ></td>
+ </ng-container>
+
<ng-container matColumnDef="comment">
<th
*matHeaderCellDef
@@ -291,7 +320,11 @@
</button>
</mat-menu>
</td>
- <td *matFooterCellDef class="px-1" mat-footer-cell></td>
+ <td
+ *matFooterCellDef
+ class="d-none d-lg-table-cell px-1"
+ mat-footer-cell
+ ></td>
</ng-container>
<tr *matHeaderRowDef="displayedColumns" mat-header-row></tr>
diff --git a/apps/client/src/app/components/accounts-table/accounts-table.component.ts b/apps/client/src/app/components/accounts-table/accounts-table.component.ts
index 3d38d67755..a7ce6e488e 100644
--- a/apps/client/src/app/components/accounts-table/accounts-table.component.ts
+++ b/apps/client/src/app/components/accounts-table/accounts-table.component.ts
@@ -60,6 +60,7 @@ export class GfAccountsTableComponent implements OnChanges, OnDestroy {
@Input() hasPermissionToOpenDetails = true;
@Input() locale = getLocale();
@Input() showActions: boolean;
+ @Input() showAllocationInPercentage: boolean;
@Input() showBalance = true;
@Input() showFooter = true;
@Input() showTransactions = true;
@@ -117,6 +118,10 @@ export class GfAccountsTableComponent implements OnChanges, OnDestroy {
this.displayedColumns.push('valueInBaseCurrency');
}
+ if (this.showAllocationInPercentage) {
+ this.displayedColumns.push('allocation');
+ }
+
this.displayedColumns.push('comment');
if (this.showActions) {
diff --git a/apps/client/src/app/components/holding-detail-dialog/holding-detail-dialog.html b/apps/client/src/app/components/holding-detail-dialog/holding-detail-dialog.html
index 4427cfcbb7..e0673a1f50 100644
--- a/apps/client/src/app/components/holding-detail-dialog/holding-detail-dialog.html
+++ b/apps/client/src/app/components/holding-detail-dialog/holding-detail-dialog.html
@@ -375,6 +375,7 @@
[deviceType]="data.deviceType"
[hasPermissionToOpenDetails]="false"
[locale]="user?.settings?.locale"
+ [showAllocationInPercentage]="user?.settings?.isExperimentalFeatures"
[showBalance]="false"
[showFooter]="false"
[showTransactions]="false"
diff --git a/libs/common/src/lib/types/account-with-value.type.ts b/libs/common/src/lib/types/account-with-value.type.ts
index 40aefa9981..d86a7ca1f2 100644
--- a/libs/common/src/lib/types/account-with-value.type.ts
+++ b/libs/common/src/lib/types/account-with-value.type.ts
@@ -1,6 +1,7 @@
import { Account as AccountModel, Platform } from '@prisma/client';
export type AccountWithValue = AccountModel & {
+ allocationInPercentage: number;
balanceInBaseCurrency: number;
platform?: Platform;
transactionCount: number;