From e1932eb5a1707165128b4d2a2190cb2057f3c0af Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Sun, 14 Nov 2021 19:06:54 +0100 Subject: [PATCH] Bugfix/exclude drafts from transaction count (#473) * Fix transactions count (exclude drafts) * Improve wording (summary page) * Update changelog --- CHANGELOG.md | 6 ++++++ apps/api/src/app/account/account.service.ts | 10 +++++++++- apps/api/src/app/portfolio/portfolio.service.ts | 10 +++++++++- .../portfolio-summary/portfolio-summary.component.html | 4 ++-- 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6aeffcaac..0e61cac07 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Unreleased + +### Fixed + +- Fixed the transactions count in the accounts table (exclude drafts) + ## 1.76.0 - 14.11.2021 ### Added diff --git a/apps/api/src/app/account/account.service.ts b/apps/api/src/app/account/account.service.ts index 58d98e5cf..159499dbb 100644 --- a/apps/api/src/app/account/account.service.ts +++ b/apps/api/src/app/account/account.service.ts @@ -85,7 +85,15 @@ export class AccountService { }); return accounts.map((account) => { - const result = { ...account, transactionCount: account.Order.length }; + let transactionCount = 0; + + for (const order of account.Order) { + if (!order.isDraft) { + transactionCount += 1; + } + } + + const result = { ...account, transactionCount }; delete result.Order; diff --git a/apps/api/src/app/portfolio/portfolio.service.ts b/apps/api/src/app/portfolio/portfolio.service.ts index a1b752e31..4f182b4c2 100644 --- a/apps/api/src/app/portfolio/portfolio.service.ts +++ b/apps/api/src/app/portfolio/portfolio.service.ts @@ -94,14 +94,22 @@ export class PortfolioService { const userCurrency = this.request.user.Settings.currency; return accounts.map((account) => { + let transactionCount = 0; + + for (const order of account.Order) { + if (!order.isDraft) { + transactionCount += 1; + } + } + const result = { ...account, + transactionCount, convertedBalance: this.exchangeRateDataService.toCurrency( account.balance, account.currency, userCurrency ), - transactionCount: account.Order.length, value: details.accounts[account.name]?.current ?? 0 }; diff --git a/apps/client/src/app/components/portfolio-summary/portfolio-summary.component.html b/apps/client/src/app/components/portfolio-summary/portfolio-summary.component.html index 9bc6d59c1..893718044 100644 --- a/apps/client/src/app/components/portfolio-summary/portfolio-summary.component.html +++ b/apps/client/src/app/components/portfolio-summary/portfolio-summary.component.html @@ -77,7 +77,7 @@
Fees for {{ summary?.ordersCount }} {summary?.ordersCount, plural, =1 - {order} other {orders}} + {transaction} other {transactions}}
- @@ -132,7 +132,7 @@
-
Cash
+
Cash (Buying Power)