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 = (
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<Account>[]) {
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 {