From cc991f9439c311217638c172111fea243f0c3d51 Mon Sep 17 00:00:00 2001 From: Thomas <4159106+dtslvr@users.noreply.github.com> Date: Sun, 4 Jun 2023 09:53:58 +0200 Subject: [PATCH] Migrate currency to unit --- .../account-detail-dialog.html | 9 +++-- .../portfolio-summary.component.html | 39 ++++++++++++------- .../position-detail-dialog.html | 27 ++++++++----- .../position/position.component.html | 3 +- .../create-or-update-activity-dialog.html | 3 +- .../app/pages/portfolio/fire/fire-page.html | 9 +++-- libs/ui/src/lib/value/value.component.html | 6 --- .../src/lib/value/value.component.stories.ts | 3 +- libs/ui/src/lib/value/value.component.ts | 17 ++++---- 9 files changed, 70 insertions(+), 46 deletions(-) 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 772b85ff8..126c33ac5 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 @@ -12,8 +12,9 @@
@@ -24,8 +25,9 @@ Cash Balance @@ -34,8 +36,9 @@ Equity diff --git a/apps/client/src/app/components/portfolio-summary/portfolio-summary.component.html b/apps/client/src/app/components/portfolio-summary/portfolio-summary.component.html index 0b0077dea..8b507f553 100644 --- a/apps/client/src/app/components/portfolio-summary/portfolio-summary.component.html +++ b/apps/client/src/app/components/portfolio-summary/portfolio-summary.component.html @@ -13,8 +13,9 @@
@@ -24,8 +25,9 @@
@@ -38,8 +40,9 @@
@@ -49,8 +52,9 @@
@@ -79,8 +83,9 @@ - @@ -93,8 +98,9 @@
@@ -121,8 +127,9 @@ @@ -132,8 +139,9 @@
@@ -152,8 +160,9 @@ > @@ -163,8 +172,9 @@
@@ -174,8 +184,9 @@
@@ -188,8 +199,9 @@
@@ -217,8 +229,9 @@
diff --git a/apps/client/src/app/components/position/position-detail-dialog/position-detail-dialog.html b/apps/client/src/app/components/position/position-detail-dialog/position-detail-dialog.html index eaaf3b782..379250fcd 100644 --- a/apps/client/src/app/components/position/position-detail-dialog/position-detail-dialog.html +++ b/apps/client/src/app/components/position/position-detail-dialog/position-detail-dialog.html @@ -12,8 +12,9 @@
@@ -40,8 +41,9 @@ i18n size="medium" [colorizeSign]="true" - [currency]="data.baseCurrency" + [isCurrency]="true" [locale]="data.locale" + [unit]="data.baseCurrency" [value]="netPerformance" >Change @@ -61,8 +63,9 @@ Average Unit Price @@ -71,8 +74,9 @@ Market Price @@ -81,9 +85,10 @@ Minimum Price @@ -92,9 +97,10 @@ Maximum Price @@ -113,8 +119,9 @@ Investment @@ -123,8 +130,9 @@ Dividend @@ -133,8 +141,9 @@ Fees diff --git a/apps/client/src/app/components/position/position.component.html b/apps/client/src/app/components/position/position.component.html index 2f6b76bd9..e173b0f00 100644 --- a/apps/client/src/app/components/position/position.component.html +++ b/apps/client/src/app/components/position/position.component.html @@ -45,8 +45,9 @@
diff --git a/apps/client/src/app/pages/portfolio/fire/fire-page.html b/apps/client/src/app/pages/portfolio/fire/fire-page.html index 4269c3d70..868d82312 100644 --- a/apps/client/src/app/pages/portfolio/fire/fire-page.html +++ b/apps/client/src/app/pages/portfolio/fire/fire-page.html @@ -59,8 +59,9 @@ per year per month diff --git a/libs/ui/src/lib/value/value.component.html b/libs/ui/src/lib/value/value.component.html index d6b01be43..61e6ecd5e 100644 --- a/libs/ui/src/lib/value/value.component.html +++ b/libs/ui/src/lib/value/value.component.html @@ -32,15 +32,9 @@ {{ formattedValue }}
- - {{ currency }} - {{ unit }} -
- {{ currency }} -
{{ unit }}
diff --git a/libs/ui/src/lib/value/value.component.stories.ts b/libs/ui/src/lib/value/value.component.stories.ts index 739b4185b..fc3e202ea 100644 --- a/libs/ui/src/lib/value/value.component.stories.ts +++ b/libs/ui/src/lib/value/value.component.stories.ts @@ -24,8 +24,9 @@ Loading.args = { export const Currency = Template.bind({}); Currency.args = { - currency: 'USD', + isCurrency: true, locale: 'en-US', + unit: 'USD', value: 7 }; diff --git a/libs/ui/src/lib/value/value.component.ts b/libs/ui/src/lib/value/value.component.ts index 2e1e74e79..d35c2d1b0 100644 --- a/libs/ui/src/lib/value/value.component.ts +++ b/libs/ui/src/lib/value/value.component.ts @@ -15,7 +15,6 @@ import { isNumber } from 'lodash'; }) export class ValueComponent implements OnChanges { @Input() colorizeSign = false; - @Input() currency = ''; @Input() icon = ''; @Input() isAbsolute = false; @Input() isCurrency = false; @@ -47,7 +46,7 @@ export class ValueComponent implements OnChanges { this.absoluteValue = Math.abs(this.value); if (this.colorizeSign) { - if (this.currency || this.isCurrency) { + if (this.isCurrency) { try { this.formattedValue = this.absoluteValue.toLocaleString( this.locale, @@ -68,6 +67,13 @@ export class ValueComponent implements OnChanges { ); } catch {} } + } else if (this.isCurrency) { + try { + this.formattedValue = this.value?.toLocaleString(this.locale, { + maximumFractionDigits: 2, + minimumFractionDigits: 2 + }); + } catch {} } else if (this.isPercent) { try { this.formattedValue = (this.value * 100).toLocaleString( @@ -78,13 +84,6 @@ export class ValueComponent implements OnChanges { } ); } catch {} - } else if (this.currency || this.isCurrency) { - try { - this.formattedValue = this.value?.toLocaleString(this.locale, { - maximumFractionDigits: 2, - minimumFractionDigits: 2 - }); - } catch {} } else if (this.precision || this.precision === 0) { try { this.formattedValue = this.value?.toLocaleString(this.locale, {