From 029b7bed9a4329ffc6448c44df864eb5f1d50fb0 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Fri, 31 Dec 2021 22:00:58 +0100 Subject: [PATCH] Bugfix/improve error handling in position api endpoint (#607) * Add guards * Update changelog --- CHANGELOG.md | 1 + apps/api/src/app/portfolio/portfolio.service.ts | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a5117615..743a80c6d 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 9a44d2d8e..815900278 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 );