Skip to content

Conversation

@mynjj
Copy link
Contributor

@mynjj mynjj commented Feb 7, 2026

Summary

A different approach to calculate trial balance excel reports. Instead of looping over accounts, dimensions, and business units and querying, have query objects that do the same in a single query (or multiple passes of such query).

Main idea of how it works: Two-pass approach

Since the report needs Starting Balance, Net Change, and Ending Balance (Balance at Date), and a single SQL aggregation can only give a sum up to a given date, the query is executed twice:

  1. First pass - filter PostingDate <= EndDate (i.e. ..EndDate):

    • For each group (Account, Dim1, Dim2) returned by the query, a buffer record is inserted.
    • The summed amount is written into both Balance (ending balance) and Net Change (as a temporary placeholder).
  2. Second pass - filter PostingDate <= StartDate - 1 (i.e. ..StartDate - 1):

    • For each group returned, the matching buffer record is found (or created if missing).
    • Starting Balance is set to the summed amount.
    • Net Change is adjusted: Net Change := (Balance at EndDate) - (Balance at StartDate - 1).
  3. End-Total fixup - After both passes, End-Total accounts are computed by summing the buffer records whose "G/L Account No." falls within the End-Total's Totaling range. This is required since the query will only return entries for Posting type accounts

And the same/analogous way for reports that use Business Unit (Consolidation report), or budget entries.

Several issues with the approach were also fixed (see tests)

Work Item(s)

Fixes AB#596634

@github-actions github-actions bot added the AL: Apps (W1) Add-on apps for W1 label Feb 7, 2026
@github-actions github-actions bot added this to the Version 28.0 milestone Feb 9, 2026
@mynjj mynjj changed the title Performant trial balance Performant trial balance Excel reports Feb 9, 2026
@mynjj mynjj marked this pull request as ready for review February 9, 2026 12:41
@mynjj mynjj requested review from a team as code owners February 9, 2026 12:41
@mynjj mynjj requested a review from a team February 9, 2026 12:43
Joshua Martínez Pineda added 2 commits February 9, 2026 14:13
dcenic
dcenic previously approved these changes Feb 9, 2026
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.

2 participants