From 6f4fd0826c12a613466eb63dc321ee40225089b3 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Fri, 1 Dec 2023 17:22:13 +0100 Subject: [PATCH] Feature/respect with excluded accounts flag in get account balances (#2697) * Respect withExcludedAccounts in getAccountBalances() * Update changelog --- CHANGELOG.md | 6 ++++++ apps/api/src/app/portfolio/portfolio.service.ts | 2 +- .../services/account-balance/account-balance.service.ts | 8 +++++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f89102f9..729b4713b 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 + +### Added + +- Respected the `withExcludedAccounts` flag in the account balance time series + ## 2.27.1 - 2023-11-28 ### Changed diff --git a/apps/api/src/app/portfolio/portfolio.service.ts b/apps/api/src/app/portfolio/portfolio.service.ts index b5bc589e6..76aef0db1 100644 --- a/apps/api/src/app/portfolio/portfolio.service.ts +++ b/apps/api/src/app/portfolio/portfolio.service.ts @@ -1075,7 +1075,7 @@ export class PortfolioService { const userCurrency = this.getUserCurrency(user); const accountBalances = await this.accountBalanceService.getAccountBalances( - { filters, user } + { filters, user, withExcludedAccounts } ); let accountBalanceItems: HistoricalDataItem[] = Object.values( diff --git a/apps/api/src/services/account-balance/account-balance.service.ts b/apps/api/src/services/account-balance/account-balance.service.ts index 33b811ef5..e1d002428 100644 --- a/apps/api/src/services/account-balance/account-balance.service.ts +++ b/apps/api/src/services/account-balance/account-balance.service.ts @@ -22,10 +22,12 @@ export class AccountBalanceService { public async getAccountBalances({ filters, - user + user, + withExcludedAccounts }: { filters?: Filter[]; user: UserWithSettings; + withExcludedAccounts?: boolean; }): Promise { const where: Prisma.AccountBalanceWhereInput = { userId: user.id }; @@ -37,6 +39,10 @@ export class AccountBalanceService { where.accountId = accountFilter.id; } + if (withExcludedAccounts === false) { + where.Account = { isExcluded: false }; + } + const balances = await this.prismaService.accountBalance.findMany({ where, orderBy: {