Browse Source

Bugfix/fix issue with value in value redaction interceptor (#1627)

* Fix issue with value in value redaction interceptor

* Fix format of world map

* Update changelog
pull/1639/head
Thomas Kaul 2 years ago
committed by GitHub
parent
commit
6aae0cc1e4
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      CHANGELOG.md
  2. 7
      apps/api/src/app/portfolio/portfolio.controller.ts
  3. 8
      apps/api/src/app/portfolio/portfolio.service.ts
  4. 2
      apps/client/src/app/components/position/position-detail-dialog/position-detail-dialog.component.ts
  5. 5
      apps/client/src/app/pages/portfolio/allocations/allocations-page.component.ts
  6. 7
      apps/client/src/app/pages/portfolio/analysis/analysis-page.component.ts
  7. 5
      apps/client/src/app/pages/public/public-page.component.ts
  8. 1
      apps/client/src/app/pages/public/public-page.html
  9. 26
      apps/client/src/app/services/data.service.ts
  10. 2
      libs/common/src/lib/interfaces/historical-data-item.interface.ts
  11. 3
      libs/common/src/lib/interfaces/portfolio-position.interface.ts
  12. 1
      libs/common/src/lib/interfaces/portfolio-public-details.interface.ts

2
CHANGELOG.md

@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- Improved the unit format (`%`) in the global heat map component of the public page
- Improved the pricing page
- Upgraded `Node.js` from version `16` to `18` (`Dockerfile`)
- Upgraded `prisma` from version `4.8.0` to `4.9.0`
@ -21,6 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- Fixed the click of unknown accounts in the portfolio proportion chart component
- Fixed an issue with `value` in the value redaction interceptor for the impersonation mode
## 1.229.0 - 2023-01-21

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

@ -131,7 +131,8 @@ export class PortfolioController {
portfolioPosition.investment / totalInvestment;
portfolioPosition.netPerformance = null;
portfolioPosition.quantity = null;
portfolioPosition.value = portfolioPosition.value / totalValue;
portfolioPosition.valueInPercentage =
portfolioPosition.value / totalValue;
}
for (const [name, { current, original }] of Object.entries(accounts)) {
@ -322,7 +323,7 @@ export class PortfolioController {
totalInvestment: new Big(totalInvestment)
.div(performanceInformation.performance.totalInvestment)
.toNumber(),
value: new Big(value)
valueInPercentage: new Big(value)
.div(performanceInformation.performance.currentValue)
.toNumber()
};
@ -437,7 +438,7 @@ export class PortfolioController {
sectors: hasDetails ? portfolioPosition.sectors : [],
symbol: portfolioPosition.symbol,
url: portfolioPosition.url,
value: portfolioPosition.value / totalValue
valueInPercentage: portfolioPosition.value / totalValue
};
}

8
apps/api/src/app/portfolio/portfolio.service.ts

@ -785,8 +785,8 @@ export class PortfolioService {
historicalDataArray.push({
averagePrice: orders[0].unitPrice,
date: firstBuyDate,
quantity: orders[0].quantity,
value: orders[0].unitPrice
marketPrice: orders[0].unitPrice,
quantity: orders[0].quantity
});
}
@ -815,9 +815,9 @@ export class PortfolioService {
historicalDataArray.push({
date,
marketPrice,
averagePrice: currentAveragePrice,
quantity: currentQuantity,
value: marketPrice
quantity: currentQuantity
});
maxPrice = Math.max(marketPrice ?? 0, maxPrice);

2
apps/client/src/app/components/position/position-detail-dialog/position-detail-dialog.component.ts

@ -111,7 +111,7 @@ export class PositionDetailDialog implements OnDestroy, OnInit {
return {
date: historicalDataItem.date,
value: historicalDataItem.value
value: historicalDataItem.marketPrice
};
}
);

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

@ -21,6 +21,7 @@ import { hasPermission, permissions } from '@ghostfolio/common/permissions';
import { Market } from '@ghostfolio/common/types';
import { translate } from '@ghostfolio/ui/i18n';
import { Account, AssetClass, DataSource } from '@prisma/client';
import { isNumber } from 'lodash';
import { DeviceDetectorService } from 'ngx-device-detector';
import { Subject } from 'rxjs';
import { distinctUntilChanged, switchMap, takeUntil } from 'rxjs/operators';
@ -339,7 +340,9 @@ export class AllocationsPageComponent implements OnDestroy, OnInit {
dataSource: position.dataSource,
name: position.name,
symbol: prettifySymbol(symbol),
value: position.value
value: isNumber(position.value)
? position.value
: position.valueInPercentage
};
}

7
apps/client/src/app/pages/portfolio/analysis/analysis-page.component.ts

@ -19,7 +19,7 @@ import { DateRange, GroupBy, ToggleOption } from '@ghostfolio/common/types';
import { translate } from '@ghostfolio/ui/i18n';
import { AssetClass, DataSource, SymbolProfile } from '@prisma/client';
import { differenceInDays } from 'date-fns';
import { sortBy } from 'lodash';
import { isNumber, sortBy } from 'lodash';
import { DeviceDetectorService } from 'ngx-device-detector';
import { Subject } from 'rxjs';
import { distinctUntilChanged, map, takeUntil } from 'rxjs/operators';
@ -312,12 +312,13 @@ export class AnalysisPageComponent implements OnDestroy, OnInit {
date,
netPerformanceInPercentage,
totalInvestment,
value
value,
valueInPercentage
} of chart) {
this.investments.push({ date, investment: totalInvestment });
this.performanceDataItems.push({
date,
value
value: isNumber(value) ? value : valueInPercentage
});
this.performanceDataItemsInPercentage.push({
date,

5
apps/client/src/app/pages/public/public-page.component.ts

@ -9,6 +9,7 @@ import {
} from '@ghostfolio/common/interfaces';
import { Market } from '@ghostfolio/common/types';
import { StatusCodes } from 'http-status-codes';
import { isNumber } from 'lodash';
import { DeviceDetectorService } from 'ngx-device-detector';
import { EMPTY, Subject } from 'rxjs';
import { catchError, takeUntil } from 'rxjs/operators';
@ -198,7 +199,9 @@ export class PublicPageComponent implements OnInit {
this.symbols[prettifySymbol(symbol)] = {
name: position.name,
symbol: prettifySymbol(symbol),
value: position.value
value: isNumber(position.value)
? position.value
: position.valueInPercentage
};
}

1
apps/client/src/app/pages/public/public-page.html

@ -77,6 +77,7 @@
</mat-card-header>
<mat-card-content>
<gf-world-map-chart
format="{0}%"
[countries]="countries"
[isInPercent]="true"
></gf-world-map-chart>

26
apps/client/src/app/services/data.service.ts

@ -41,7 +41,7 @@ import { AccountWithValue, DateRange, GroupBy } from '@ghostfolio/common/types';
import { translate } from '@ghostfolio/ui/i18n';
import { DataSource, Order as OrderModel } from '@prisma/client';
import { format, parseISO } from 'date-fns';
import { cloneDeep, groupBy } from 'lodash';
import { cloneDeep, groupBy, isNumber } from 'lodash';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
@ -299,6 +299,12 @@ export class DataService {
].dateOfFirstActivity
? parseISO(response.holdings[symbol].dateOfFirstActivity)
: undefined;
response.holdings[symbol].value = isNumber(
response.holdings[symbol].value
)
? response.holdings[symbol].value
: response.holdings[symbol].valueInPercentage;
}
}
@ -333,8 +339,22 @@ export class DataService {
}
public fetchPortfolioPublic(aId: string) {
return this.http.get<PortfolioPublicDetails>(
`/api/v1/portfolio/public/${aId}`
return this.http
.get<PortfolioPublicDetails>(`/api/v1/portfolio/public/${aId}`)
.pipe(
map((response) => {
if (response.holdings) {
for (const symbol of Object.keys(response.holdings)) {
response.holdings[symbol].value = isNumber(
response.holdings[symbol].value
)
? response.holdings[symbol].value
: response.holdings[symbol].valueInPercentage;
}
}
return response;
})
);
}

2
libs/common/src/lib/interfaces/historical-data-item.interface.ts

@ -2,9 +2,11 @@ export interface HistoricalDataItem {
averagePrice?: number;
date: string;
grossPerformancePercent?: number;
marketPrice?: number;
netPerformance?: number;
netPerformanceInPercentage?: number;
quantity?: number;
totalInvestment?: number;
value?: number;
valueInPercentage?: number;
}

3
libs/common/src/lib/interfaces/portfolio-position.interface.ts

@ -30,5 +30,6 @@ export interface PortfolioPosition {
symbol: string;
type?: string;
url?: string;
value: number;
value?: number;
valueInPercentage?: number;
}

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

@ -18,6 +18,7 @@ export interface PortfolioPublicDetails {
| 'symbol'
| 'url'
| 'value'
| 'valueInPercentage'
>;
};
}

Loading…
Cancel
Save