Browse Source

Add value in percentage

pull/1914/head
Thomas 2 years ago
parent
commit
c65893e6da
  1. 2
      apps/api/src/app/portfolio/portfolio.controller.ts
  2. 17
      apps/client/src/app/pages/portfolio/allocations/allocations-page.component.ts
  3. 1
      libs/common/src/lib/interfaces/portfolio-details.interface.ts

2
apps/api/src/app/portfolio/portfolio.controller.ts

@ -137,7 +137,7 @@ export class PortfolioController {
} }
for (const [name, { valueInBaseCurrency }] of Object.entries(accounts)) { for (const [name, { valueInBaseCurrency }] of Object.entries(accounts)) {
accounts[name].valueInBaseCurrency = valueInBaseCurrency / totalValue; accounts[name].valueInPercentage = valueInBaseCurrency / totalValue;
} }
} }

17
apps/client/src/app/pages/portfolio/allocations/allocations-page.component.ts

@ -249,13 +249,22 @@ export class AllocationsPageComponent implements OnDestroy, OnInit {
public initializeAnalysisData() { public initializeAnalysisData() {
this.initialize(); this.initialize();
for (const [id, { name, valueInBaseCurrency }] of Object.entries( for (const [
this.portfolioDetails.accounts id,
)) { { name, valueInBaseCurrency, valueInPercentage }
] of Object.entries(this.portfolioDetails.accounts)) {
let value = 0;
if (this.hasImpersonationId) {
value = valueInPercentage;
} else {
value = valueInBaseCurrency;
}
this.accounts[id] = { this.accounts[id] = {
id, id,
name, name,
value: valueInBaseCurrency value
}; };
} }

1
libs/common/src/lib/interfaces/portfolio-details.interface.ts

@ -10,6 +10,7 @@ export interface PortfolioDetails {
currency: string; currency: string;
name: string; name: string;
valueInBaseCurrency: number; valueInBaseCurrency: number;
valueInPercentage?: number;
}; };
}; };
filteredValueInBaseCurrency?: number; filteredValueInBaseCurrency?: number;

Loading…
Cancel
Save