Skip to content

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

Task/refactor rounding logic in holding detail dialog (#7199)

Thomas Kaul2eabd95cb461
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b0f53a3b92..468ca68ccf 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
+- Refactored the rounding logic in the holding detail dialog
- Refactored the rounding logic in the treemap chart component
- Restricted the modification of activity tags in the impersonation mode
- Hardened the endpoint of the public access for portfolio sharing by restricting it to public accesses
diff --git a/apps/client/src/app/components/holding-detail-dialog/holding-detail-dialog.component.ts b/apps/client/src/app/components/holding-detail-dialog/holding-detail-dialog.component.ts
index 6fa3a48534..3ddcd4e194 100644
--- a/apps/client/src/app/components/holding-detail-dialog/holding-detail-dialog.component.ts
+++ b/apps/client/src/app/components/holding-detail-dialog/holding-detail-dialog.component.ts
@@ -77,7 +77,7 @@ import {
swapVerticalOutline,
walletOutline
} from 'ionicons/icons';
-import { isNumber } from 'lodash';
+import { isNumber, round } from 'lodash';
import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader';
import { switchMap } from 'rxjs/operators';
@@ -170,6 +170,7 @@ export class GfHoldingDetailDialogComponent implements OnInit {
protected quantity: number;
protected quantityPrecision = 2;
protected reportDataGlitchMail: string;
+ protected readonly round = round;
protected readonly routerLinkAdminControlMarketData =
internalRoutes.adminControl.subRoutes.marketData.routerLink;
protected sectors: {
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 ff1d19cc3f..0007bedc55 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
@@ -118,8 +118,10 @@
i18n
size="medium"
[class.text-danger]="
- marketPriceMin?.toFixed(2) === marketPrice?.toFixed(2) &&
- marketPriceMax?.toFixed(2) !== marketPriceMin?.toFixed(2)
+ round(marketPriceMin, marketPriceMinPrecision) ===
+ round(marketPrice, marketPricePrecision) &&
+ round(marketPriceMax, marketPriceMaxPrecision) !==
+ round(marketPriceMin, marketPriceMinPrecision)
"
[isCurrency]="true"
[locale]="data.locale"
@@ -134,8 +136,10 @@
i18n
size="medium"
[class.text-success]="
- marketPriceMax?.toFixed(2) === marketPrice?.toFixed(2) &&
- marketPriceMax?.toFixed(2) !== marketPriceMin?.toFixed(2)
+ round(marketPriceMax, marketPriceMaxPrecision) ===
+ round(marketPrice, marketPricePrecision) &&
+ round(marketPriceMax, marketPriceMaxPrecision) !==
+ round(marketPriceMin, marketPriceMinPrecision)
"
[isCurrency]="true"
[locale]="data.locale"