From bda862a414b54df8f8924dbd2d6c951e5add8fdb Mon Sep 17 00:00:00 2001 From: Thomas <4159106+dtslvr@users.noreply.github.com> Date: Sat, 22 Jul 2023 09:20:17 +0200 Subject: [PATCH] Refactor value to valueInBaseCurrency --- .../allocations/allocations-page.component.ts | 6 +++--- .../portfolio-proportion-chart.component.ts | 20 ++++++++++--------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/apps/client/src/app/pages/portfolio/allocations/allocations-page.component.ts b/apps/client/src/app/pages/portfolio/allocations/allocations-page.component.ts index 6d2ada8b0..b9dd990c5 100644 --- a/apps/client/src/app/pages/portfolio/allocations/allocations-page.component.ts +++ b/apps/client/src/app/pages/portfolio/allocations/allocations-page.component.ts @@ -81,7 +81,7 @@ export class AllocationsPageComponent implements OnDestroy, OnInit { dataSource?: DataSource; name: string; symbol: string; - value: number; + valueInBaseCurrency: number; }; }; @@ -259,7 +259,7 @@ export class AllocationsPageComponent implements OnDestroy, OnInit { [UNKNOWN_KEY]: { name: UNKNOWN_KEY, symbol: UNKNOWN_KEY, - value: 0 + valueInBaseCurrency: 0 } }; } @@ -389,7 +389,7 @@ export class AllocationsPageComponent implements OnDestroy, OnInit { dataSource: position.dataSource, name: position.name, symbol: prettifySymbol(symbol), - value: isNumber(position.valueInBaseCurrency) + valueInBaseCurrency: isNumber(position.valueInBaseCurrency) ? position.valueInBaseCurrency : position.valueInPercentage }; diff --git a/libs/ui/src/lib/portfolio-proportion-chart/portfolio-proportion-chart.component.ts b/libs/ui/src/lib/portfolio-proportion-chart/portfolio-proportion-chart.component.ts index ec0a63eea..b994338a7 100644 --- a/libs/ui/src/lib/portfolio-proportion-chart/portfolio-proportion-chart.component.ts +++ b/libs/ui/src/lib/portfolio-proportion-chart/portfolio-proportion-chart.component.ts @@ -44,10 +44,12 @@ export class PortfolioProportionChartComponent @Input() maxItems?: number; @Input() showLabels = false; @Input() positions: { - [symbol: string]: Pick & { + [symbol: string]: Pick< + PortfolioPosition, + 'type' | 'valueInBaseCurrency' + > & { dataSource?: DataSource; name: string; - value: number; }; } = {}; @@ -105,7 +107,7 @@ export class PortfolioProportionChartComponent chartData[this.positions[symbol][this.keys[0]].toUpperCase()].value = chartData[ this.positions[symbol][this.keys[0]].toUpperCase() - ].value.plus(this.positions[symbol].value); + ].value.plus(this.positions[symbol].valueInBaseCurrency); if ( chartData[this.positions[symbol][this.keys[0]].toUpperCase()] @@ -117,19 +119,19 @@ export class PortfolioProportionChartComponent chartData[ this.positions[symbol][this.keys[0]].toUpperCase() ].subCategory[this.positions[symbol][this.keys[1]]].value.plus( - this.positions[symbol].value + this.positions[symbol].valueInBaseCurrency ); } else { chartData[ this.positions[symbol][this.keys[0]].toUpperCase() ].subCategory[this.positions[symbol][this.keys[1]] ?? UNKNOWN_KEY] = - { value: new Big(this.positions[symbol].value) }; + { value: new Big(this.positions[symbol].valueInBaseCurrency) }; } } else { chartData[this.positions[symbol][this.keys[0]].toUpperCase()] = { name: this.positions[symbol][this.keys[0]], subCategory: {}, - value: new Big(this.positions[symbol].value ?? 0) + value: new Big(this.positions[symbol].valueInBaseCurrency ?? 0) }; if (this.positions[symbol][this.keys[1]]) { @@ -137,7 +139,7 @@ export class PortfolioProportionChartComponent this.positions[symbol][this.keys[0]].toUpperCase() ].subCategory = { [this.positions[symbol][this.keys[1]]]: { - value: new Big(this.positions[symbol].value) + value: new Big(this.positions[symbol]?.valueInBaseCurrency ?? 0) } }; } @@ -145,7 +147,7 @@ export class PortfolioProportionChartComponent } else { if (chartData[UNKNOWN_KEY]) { chartData[UNKNOWN_KEY].value = chartData[UNKNOWN_KEY].value.plus( - this.positions[symbol].value + this.positions[symbol].valueInBaseCurrency ); } else { chartData[UNKNOWN_KEY] = { @@ -153,7 +155,7 @@ export class PortfolioProportionChartComponent subCategory: this.keys[1] ? { [this.keys[1]]: { value: new Big(0) } } : undefined, - value: new Big(this.positions[symbol].value) + value: new Big(this.positions[symbol].valueInBaseCurrency) }; } }