From 3797352b191417e18055886a99dcbeb947ad44b8 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Sun, 10 Aug 2025 09:05:21 +0200 Subject: [PATCH] Improve dynamic numerical precision --- .../account-detail-dialog.component.ts | 18 ++++++++++++++++++ .../account-detail-dialog.html | 2 ++ 2 files changed, 20 insertions(+) diff --git a/apps/client/src/app/components/account-detail-dialog/account-detail-dialog.component.ts b/apps/client/src/app/components/account-detail-dialog/account-detail-dialog.component.ts index 16cd468e8..c718df686 100644 --- a/apps/client/src/app/components/account-detail-dialog/account-detail-dialog.component.ts +++ b/apps/client/src/app/components/account-detail-dialog/account-detail-dialog.component.ts @@ -2,6 +2,7 @@ import { CreateAccountBalanceDto } from '@ghostfolio/api/app/account-balance/cre import { Activity } from '@ghostfolio/api/app/order/interfaces/activities.interface'; import { DataService } from '@ghostfolio/client/services/data.service'; import { UserService } from '@ghostfolio/client/services/user/user.service'; +import { NUMERICAL_PRECISION_THRESHOLD_6_FIGURES } from '@ghostfolio/common/config'; import { DATE_FORMAT, downloadAsFile } from '@ghostfolio/common/helper'; import { AccountBalancesResponse, @@ -51,9 +52,11 @@ export class AccountDetailDialog implements OnDestroy, OnInit { public accountBalances: AccountBalancesResponse['balances']; public activities: OrderWithAccount[]; public balance: number; + public balancePrecision = 2; public currency: string; public dataSource: MatTableDataSource; public equity: number; + public equityPrecision = 2; public hasPermissionToDeleteAccountBalance: boolean; public historicalDataItems: HistoricalDataItem[]; public holdings: PortfolioPosition[]; @@ -188,10 +191,25 @@ export class AccountDetailDialog implements OnDestroy, OnInit { valueInBaseCurrency }) => { this.balance = balance; + + if ( + this.balance >= NUMERICAL_PRECISION_THRESHOLD_6_FIGURES && + this.data.deviceType === 'mobile' + ) { + this.balancePrecision = 0; + } + this.currency = currency; if (isNumber(balance) && isNumber(value)) { this.equity = new Big(value).minus(balance).toNumber(); + + if ( + this.data.deviceType === 'mobile' && + this.equity >= NUMERICAL_PRECISION_THRESHOLD_6_FIGURES + ) { + this.equityPrecision = 0; + } } else { this.equity = null; } diff --git a/apps/client/src/app/components/account-detail-dialog/account-detail-dialog.html b/apps/client/src/app/components/account-detail-dialog/account-detail-dialog.html index 45d88fc78..4e86ef5ea 100644 --- a/apps/client/src/app/components/account-detail-dialog/account-detail-dialog.html +++ b/apps/client/src/app/components/account-detail-dialog/account-detail-dialog.html @@ -42,6 +42,7 @@ size="medium" [isCurrency]="true" [locale]="user?.settings?.locale" + [precision]="balancePrecision" [unit]="currency" [value]="balance" >Cash BalanceEquity