Skip to content

Single-pass totals computation for Trial Balance Excel (Totaling accounts)#8565

Open
mynjj wants to merge 1 commit into
mainfrom
bugs/tb-totaling-accs
Open

Single-pass totals computation for Trial Balance Excel (Totaling accounts)#8565
mynjj wants to merge 1 commit into
mainfrom
bugs/tb-totaling-accs

Conversation

@mynjj

@mynjj mynjj commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Summary

The query-based Trial Balance Excel report (codeunit 4410 "Trial Balance") synthesized Total/End-Total rows by looping over every Total account and, for each one, re-filtering the buffer and CalcSums-ing once per distinct (Dimension 1, Dimension 2, Business Unit) combination. On charts of accounts with many totals this is O(totals × combinations) passes over the buffer and dominated the cost of large trial balances.

This change computes all totals in a single sweep:

  • BuildAccountToTotalsMap maps each posting account to the list of totals whose Totaling range contains it.
  • DistributePostingRowsToTotals sweeps the posting rows once, accumulating each row into every containing total's in-memory buffer (keyed by account + dimensions + business unit + period).
  • MergeTotalsIntoBuffer runs the budget comparison / all-zero checks and inserts the resulting totals.

Because the map is built only from posting accounts, a parent End-Total whose range spans a nested child End-Total's number no longer re-sums the child's already-inserted buffer row — fixing a latent double-counting bug for nested totals.

Fixes AB#638251

Test plan

  • New QueryPathDoesNotDoubleCountNestedTotals verifies a parent End-Total spanning a nested child End-Total counts the underlying posting amount once
  • Existing Trial Balance Excel test suite green locally

@mynjj mynjj force-pushed the bugs/tb-totaling-accs branch from 7bdcefa to ced97cc Compare June 10, 2026 16:09
@mynjj mynjj requested a review from a team June 11, 2026 19:13
@mynjj mynjj enabled auto-merge (squash) June 11, 2026 19:23
mynjj added a commit that referenced this pull request Jun 12, 2026
…g accounts) (#8568)

Backport of #8565. Fixes
[AB#638253](https://dynamicssmb2.visualstudio.com/1fcb79e7-ab07-432a-a3c6-6cf5a88ba4a5/_workitems/edit/638253).

Co-authored-by: Joshua Martínez Pineda <diegojoshuam@microsoft.com>
mynjj added a commit that referenced this pull request Jun 12, 2026
…g accounts) (#8567)

Backport of #8565. Fixes
[AB#638254](https://dynamicssmb2.visualstudio.com/1fcb79e7-ab07-432a-a3c6-6cf5a88ba4a5/_workitems/edit/638254).

Co-authored-by: Joshua Martínez Pineda <diegojoshuam@microsoft.com>
mynjj added a commit that referenced this pull request Jun 12, 2026
…g accounts) (#8569)

Backport of #8565. Fixes
[AB#638252](https://dynamicssmb2.visualstudio.com/1fcb79e7-ab07-432a-a3c6-6cf5a88ba4a5/_workitems/edit/638252).

Co-authored-by: Joshua Martínez Pineda <diegojoshuam@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AL: Apps (W1) Add-on apps for W1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant