Browse Source

fix: display cryptocurrency quantities with asset precision in holdings table

pull/7557/head
“Sebastian 2 weeks ago
parent
commit
39c2034ff6
  1. 2
      libs/ui/src/lib/holdings-table/holdings-table.component.html
  2. 24
      libs/ui/src/lib/holdings-table/holdings-table.component.ts

2
libs/ui/src/lib/holdings-table/holdings-table.component.html

@ -80,9 +80,9 @@
>
<div class="d-flex justify-content-end">
<gf-value
[isCurrency]="true"
[isLoading]="isLoading()"
[locale]="locale()"
[precision]="getQuantityPrecision(element)"
[value]="element.quantity"
/>
</div>

24
libs/ui/src/lib/holdings-table/holdings-table.component.ts

@ -1,3 +1,4 @@
import { NUMERICAL_PRECISION_THRESHOLD_6_FIGURES } from '@ghostfolio/common/config';
import {
canOpenHoldingDetail,
getLocale,
@ -7,6 +8,7 @@ import {
AssetProfileIdentifier,
PortfolioPosition
} from '@ghostfolio/common/interfaces';
import { AssetSubClass } from '@prisma/client';
import {
CUSTOM_ELEMENTS_SCHEMA,
@ -103,6 +105,28 @@ export class GfHoldingsTableComponent {
return this.hasPermissionToOpenDetails() && canOpenHoldingDetail(holding);
}
protected getQuantityPrecision(holding: PortfolioPosition): number {
if (Number.isInteger(holding.quantity)) {
return 0;
}
if (holding.assetProfile.assetSubClass === AssetSubClass.CRYPTOCURRENCY) {
if (holding.quantity < 10) {
return 8;
}
if (holding.quantity < 1000) {
return 6;
}
if (holding.quantity >= NUMERICAL_PRECISION_THRESHOLD_6_FIGURES) {
return 0;
}
}
return 2;
}
protected onOpenHoldingDialog({
dataSource,
symbol

Loading…
Cancel
Save