Browse Source

Improve grouping of same assets with diverging names

pull/6619/head
Thomas Kaul 1 week ago
parent
commit
19e3b04060
  1. 32
      apps/client/src/app/pages/portfolio/allocations/allocations-page.component.ts

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

@ -405,17 +405,22 @@ export class GfAllocationsPageComponent implements OnInit {
}
if (position.holdings.length > 0) {
for (const holding of position.holdings) {
const { allocationInPercentage, name, valueInBaseCurrency } =
holding;
if (this.topHoldingsMap[name]?.value) {
this.topHoldingsMap[name].value += isNumber(valueInBaseCurrency)
for (const {
allocationInPercentage,
name,
valueInBaseCurrency
} of position.holdings) {
const normalizedAssetName = this.normalizeAssetName(name);
if (this.topHoldingsMap[normalizedAssetName]?.value) {
this.topHoldingsMap[normalizedAssetName].value += isNumber(
valueInBaseCurrency
)
? valueInBaseCurrency
: allocationInPercentage *
this.portfolioDetails.holdings[symbol].valueInPercentage;
} else {
this.topHoldingsMap[name] = {
this.topHoldingsMap[normalizedAssetName] = {
name,
value: isNumber(valueInBaseCurrency)
? valueInBaseCurrency
@ -518,7 +523,10 @@ export class GfAllocationsPageComponent implements OnInit {
if (holding.holdings.length > 0) {
const currentParentHolding = holding.holdings.find(
(parentHolding) => {
return parentHolding.name === name;
return (
this.normalizeAssetName(parentHolding.name) ===
this.normalizeAssetName(name)
);
}
);
@ -555,6 +563,14 @@ export class GfAllocationsPageComponent implements OnInit {
}
}
private normalizeAssetName(name: string) {
if (!name) {
return '';
}
return name.trim().toLowerCase();
}
private openAccountDetailDialog(aAccountId: string) {
const dialogRef = this.dialog.open<
GfAccountDetailDialogComponent,

Loading…
Cancel
Save