From a5f0f48ddbd0b673bd1842568f43d0d2e47b8902 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Sun, 30 Apr 2023 19:20:17 +0200 Subject: [PATCH] Fix accounts page (#1908) * Add guards * Update changelog --- CHANGELOG.md | 4 ++++ apps/api/src/app/portfolio/portfolio.service.ts | 11 ++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6974ddf5..b9645b9d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Split the environment variable `DATA_SOURCE_PRIMARY` in `DATA_SOURCE_EXCHANGE_RATES` and `DATA_SOURCE_IMPORT` +### Fixed + +- Fixed the exception on the accounts page + ## 1.262.0 - 2023-04-29 ### Added diff --git a/apps/api/src/app/portfolio/portfolio.service.ts b/apps/api/src/app/portfolio/portfolio.service.ts index 1b839977..3536169f 100644 --- a/apps/api/src/app/portfolio/portfolio.service.ts +++ b/apps/api/src/app/portfolio/portfolio.service.ts @@ -466,9 +466,10 @@ export class PortfolioService { cashDetails.balanceInBaseCurrency ); - const isFilteredByAccount = filters.some((filter) => { - return filter.type === 'ACCOUNT'; - }); + const isFilteredByAccount = + filters?.some((filter) => { + return filter.type === 'ACCOUNT'; + }) ?? false; let filteredValueInBaseCurrency = isFilteredByAccount ? totalValueInBaseCurrency @@ -571,11 +572,11 @@ export class PortfolioService { }; } - const isFilteredByCash = filters.some((filter) => { + const isFilteredByCash = filters?.some((filter) => { return filter.type === 'ASSET_CLASS' && filter.id === 'CASH'; }); - if (filters.length === 0 || isFilteredByCash || isFilteredByAccount) { + if (filters?.length === 0 || isFilteredByAccount || isFilteredByCash) { const cashPositions = await this.getCashPositions({ cashDetails, userCurrency,