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 <noreply@anthropic.com>
This commit is contained in:
Ahmed Bouhuolia
2026-02-16 15:27:33 +02:00
parent a96ced10db
commit 8ad1be1d52

View File

@@ -172,8 +172,11 @@ export class TrialBalanceSheet extends FinancialSheet {
private filterNoneTransactions = ( private filterNoneTransactions = (
accountNode: ITrialBalanceAccount accountNode: ITrialBalanceAccount
): boolean => { ): boolean => {
const accountLedger = this.repository.totalAccountsLedger.whereAccountId( const depsAccountsIds =
accountNode.id, this.repository.accountsDepGraph.dependenciesOf(accountNode.id);
const accountLedger = this.repository.totalAccountsLedger.whereAccountsIds(
[accountNode.id, ...depsAccountsIds]
); );
return !accountLedger.isEmpty(); return !accountLedger.isEmpty();
}; };
@@ -241,8 +244,8 @@ export class TrialBalanceSheet extends FinancialSheet {
*/ */
private accountsSection(accounts: ModelObject<Account>[]) { private accountsSection(accounts: ModelObject<Account>[]) {
return R.compose( return R.compose(
this.nestedAccountsNode,
this.accountsFilter, this.accountsFilter,
this.nestedAccountsNode,
this.accountsMapper this.accountsMapper
)(accounts); )(accounts);
} }
@@ -250,7 +253,6 @@ export class TrialBalanceSheet extends FinancialSheet {
/** /**
* Retrieve trial balance sheet statement data. * Retrieve trial balance sheet statement data.
* Note: Retruns null in case there is no transactions between the given date periods. * Note: Retruns null in case there is no transactions between the given date periods.
*
* @return {ITrialBalanceSheetData} * @return {ITrialBalanceSheetData}
*/ */
public reportData(): ITrialBalanceSheetData { public reportData(): ITrialBalanceSheetData {