From 8ad1be1d52f4af86e28d9dfad479b0381bca72d7 Mon Sep 17 00:00:00 2001 From: Ahmed Bouhuolia Date: Mon, 16 Feb 2026 15:27:33 +0200 Subject: [PATCH] fix: correct trial balance sheet filtering logic - Include child account transactions when filtering parent accounts - Fix order of operations in accounts section mapping - Ensure accounts with child transactions are not incorrectly filtered out Co-Authored-By: Claude Opus 4.6 --- .../modules/TrialBalanceSheet/TrialBalanceSheet.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/server/src/modules/FinancialStatements/modules/TrialBalanceSheet/TrialBalanceSheet.ts b/packages/server/src/modules/FinancialStatements/modules/TrialBalanceSheet/TrialBalanceSheet.ts index 1cee9693a..790c69800 100644 --- a/packages/server/src/modules/FinancialStatements/modules/TrialBalanceSheet/TrialBalanceSheet.ts +++ b/packages/server/src/modules/FinancialStatements/modules/TrialBalanceSheet/TrialBalanceSheet.ts @@ -172,8 +172,11 @@ export class TrialBalanceSheet extends FinancialSheet { private filterNoneTransactions = ( accountNode: ITrialBalanceAccount ): boolean => { - const accountLedger = this.repository.totalAccountsLedger.whereAccountId( - accountNode.id, + const depsAccountsIds = + this.repository.accountsDepGraph.dependenciesOf(accountNode.id); + + const accountLedger = this.repository.totalAccountsLedger.whereAccountsIds( + [accountNode.id, ...depsAccountsIds] ); return !accountLedger.isEmpty(); }; @@ -241,8 +244,8 @@ export class TrialBalanceSheet extends FinancialSheet { */ private accountsSection(accounts: ModelObject[]) { return R.compose( - this.nestedAccountsNode, this.accountsFilter, + this.nestedAccountsNode, this.accountsMapper )(accounts); } @@ -250,7 +253,6 @@ export class TrialBalanceSheet extends FinancialSheet { /** * Retrieve trial balance sheet statement data. * Note: Retruns null in case there is no transactions between the given date periods. - * * @return {ITrialBalanceSheetData} */ public reportData(): ITrialBalanceSheetData {