Skip to content

Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍

Bugfix/improve error handling in position api endpoint (#607)

Thomas Kaul029b7bed9a43
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7a51176153..743a80c6d3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Hid the data provider warning while loading
- Fixed an exception with the market state caused by a failed data provider request
+- Fixed an exception in the portfolio position endpoint
- Fixed the reload of the position detail dialog (with query parameters)
## 1.98.0 - 29.12.2021
diff --git a/apps/api/src/app/portfolio/portfolio.service.ts b/apps/api/src/app/portfolio/portfolio.service.ts
index 9a44d2d8ea..8159002785 100644
--- a/apps/api/src/app/portfolio/portfolio.service.ts
+++ b/apps/api/src/app/portfolio/portfolio.service.ts
@@ -447,17 +447,17 @@ export class PortfolioService {
// Convert investment, gross and net performance to currency of user
const userCurrency = this.request.user.Settings.currency;
const investment = this.exchangeRateDataService.toCurrency(
- position.investment.toNumber(),
+ position.investment?.toNumber(),
currency,
userCurrency
);
const grossPerformance = this.exchangeRateDataService.toCurrency(
- position.grossPerformance.toNumber(),
+ position.grossPerformance?.toNumber(),
currency,
userCurrency
);
const netPerformance = this.exchangeRateDataService.toCurrency(
- position.netPerformance.toNumber(),
+ position.netPerformance?.toNumber(),
currency,
userCurrency
);