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)) {
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() {
this.initialize();
for (const [id, { name, valueInBaseCurrency }] of Object.entries(
this.portfolioDetails.accounts
)) {
for (const [
id,
{ name, valueInBaseCurrency, valueInPercentage }
] of Object.entries(this.portfolioDetails.accounts)) {
let value = 0;
if (this.hasImpersonationId) {
value = valueInPercentage;
} else {
value = valueInBaseCurrency;
}
this.accounts[id] = {
id,
name,
value: valueInBaseCurrency
value
};
}

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

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

Loading…
Cancel
Save