From 703a96f4db157da46c7da387793bef54ffc1ccfe Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Sat, 23 Sep 2023 19:45:15 +0200 Subject: [PATCH 1/2] Add guard (#2377) --- libs/common/src/lib/helper.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/common/src/lib/helper.ts b/libs/common/src/lib/helper.ts index 54c58c4cb..03fc250b8 100644 --- a/libs/common/src/lib/helper.ts +++ b/libs/common/src/lib/helper.ts @@ -294,7 +294,7 @@ export const DATE_FORMAT_YEARLY = 'yyyy'; export function parseDate(date: string): Date | null { // Transform 'yyyyMMdd' format to supported format by parse function - if (date.length === 8) { + if (date?.length === 8) { const match = date.match(/^(\d{4})(\d{2})(\d{2})$/); if (match) { From 0f7c6ff0fe12292492fc28074227eabbd60a51d0 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Sat, 23 Sep 2023 19:52:28 +0200 Subject: [PATCH 2/2] Bugfix/fix asset class of cash position for empty account (#2378) * Fix assetClass and assetSubClass * Update changelog --- CHANGELOG.md | 4 ++++ apps/api/src/app/portfolio/portfolio.controller.ts | 10 ++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 32d4fd62f..5e4445294 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added support for dates in `DD.MM.YYYY` format in the activities import - Set up the language localization for Türkçe (`tr`) +### Fixed + +- Fixed an issue with the cash position in the holdings table + ## 2.4.0 - 2023-09-19 ### Added diff --git a/apps/api/src/app/portfolio/portfolio.controller.ts b/apps/api/src/app/portfolio/portfolio.controller.ts index ef6f3af99..ff3161280 100644 --- a/apps/api/src/app/portfolio/portfolio.controller.ts +++ b/apps/api/src/app/portfolio/portfolio.controller.ts @@ -173,8 +173,14 @@ export class PortfolioController { for (const [symbol, portfolioPosition] of Object.entries(holdings)) { holdings[symbol] = { ...portfolioPosition, - assetClass: hasDetails ? portfolioPosition.assetClass : undefined, - assetSubClass: hasDetails ? portfolioPosition.assetSubClass : undefined, + assetClass: + hasDetails || portfolioPosition.assetClass === 'CASH' + ? portfolioPosition.assetClass + : undefined, + assetSubClass: + hasDetails || portfolioPosition.assetSubClass === 'CASH' + ? portfolioPosition.assetSubClass + : undefined, countries: hasDetails ? portfolioPosition.countries : [], currency: hasDetails ? portfolioPosition.currency : undefined, markets: hasDetails ? portfolioPosition.markets : undefined,