From 8898d02442703dbe02fdb4f5d8d42d91e0f3e2c0 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Sat, 18 Nov 2023 11:05:05 +0100 Subject: [PATCH] Bugfix/fix cannot read properties of undefined reading items in get position (#2667) * Fix "Cannot read properties of undefined (reading 'items')" * Update changelog --- CHANGELOG.md | 4 ++++ apps/api/src/app/portfolio/portfolio.service.ts | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f5fae02f..2ca0f9fbd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Upgraded `http-status-codes` from version `2.2.0` to `2.3.0` +### Fixed + +- Handled reading items from missing transaction point while getting the position (`getPosition()`) in portfolio service + ## 2.24.0 - 2023-11-16 ### Changed diff --git a/apps/api/src/app/portfolio/portfolio.service.ts b/apps/api/src/app/portfolio/portfolio.service.ts index 525273253..2a701aab5 100644 --- a/apps/api/src/app/portfolio/portfolio.service.ts +++ b/apps/api/src/app/portfolio/portfolio.service.ts @@ -879,7 +879,7 @@ export class PortfolioService { let currentAveragePrice = 0; let currentQuantity = 0; - const currentSymbol = transactionPoints[j].items.find( + const currentSymbol = transactionPoints[j]?.items.find( ({ symbol }) => { return symbol === aSymbol; }