Browse Source

Improve numerical precision in holding detail dialog

pull/3584/head
Thomas Kaul 1 year ago
parent
commit
cbbe77fcee
  1. 16
      apps/client/src/app/components/holding-detail-dialog/holding-detail-dialog.component.ts
  2. 4
      apps/client/src/app/components/portfolio-performance/portfolio-performance.component.ts
  3. 3
      libs/ui/src/lib/value/value.component.ts

16
apps/client/src/app/components/holding-detail-dialog/holding-detail-dialog.component.ts

@ -167,7 +167,10 @@ export class GfHoldingDetailDialogComponent implements OnDestroy, OnInit {
this.dataSource = new MatTableDataSource(orders.reverse());
this.dividendInBaseCurrency = dividendInBaseCurrency;
if (this.dividendInBaseCurrency >= NUMERICAL_PRECISION_THRESHOLD) {
if (
this.data.deviceType === 'mobile' &&
this.dividendInBaseCurrency >= NUMERICAL_PRECISION_THRESHOLD
) {
this.dividendInBaseCurrencyPrecision = 0;
}
@ -193,7 +196,10 @@ export class GfHoldingDetailDialogComponent implements OnDestroy, OnInit {
this.investment = investment;
if (this.investment >= NUMERICAL_PRECISION_THRESHOLD) {
if (
this.data.deviceType === 'mobile' &&
this.investment >= NUMERICAL_PRECISION_THRESHOLD
) {
this.investmentPrecision = 0;
}
@ -202,7 +208,10 @@ export class GfHoldingDetailDialogComponent implements OnDestroy, OnInit {
this.minPrice = minPrice;
this.netPerformance = netPerformance;
if (this.netPerformance >= NUMERICAL_PRECISION_THRESHOLD) {
if (
this.data.deviceType === 'mobile' &&
this.netPerformance >= NUMERICAL_PRECISION_THRESHOLD
) {
this.netPerformancePrecision = 0;
}
@ -215,6 +224,7 @@ export class GfHoldingDetailDialogComponent implements OnDestroy, OnInit {
netPerformanceWithCurrencyEffect;
if (
this.data.deviceType === 'mobile' &&
this.netPerformanceWithCurrencyEffect >=
NUMERICAL_PRECISION_THRESHOLD
) {

4
apps/client/src/app/components/portfolio-performance/portfolio-performance.component.ts

@ -1,3 +1,4 @@
import { NUMERICAL_PRECISION_THRESHOLD } from '@ghostfolio/common/config';
import {
getLocale,
getNumberFormatDecimal,
@ -54,7 +55,8 @@ export class PortfolioPerformanceComponent implements OnChanges, OnInit {
decimal: getNumberFormatDecimal(this.locale),
decimalPlaces:
this.deviceType === 'mobile' &&
this.performance?.currentValueInBaseCurrency >= 100000
this.performance?.currentValueInBaseCurrency >=
NUMERICAL_PRECISION_THRESHOLD
? 0
: 2,
duration: 1,

3
libs/ui/src/lib/value/value.component.ts

@ -129,8 +129,7 @@ export class GfValueComponent implements OnChanges {
this.isNumber = false;
this.isString = false;
this.locale = this.locale || getLocale();
this.precision =
this.precision || this.precision === 0 ? this.precision : 2;
this.precision = this.precision >= 0 ? this.precision : 2;
this.useAbsoluteValue = false;
}
}

Loading…
Cancel
Save