Performant trial balance Excel reports #6527
Open
+690
−70
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
First pass - filter
PostingDate <= EndDate(i.e...EndDate):Balance(ending balance) andNet Change(as a temporary placeholder).Second pass - filter
PostingDate <= StartDate - 1(i.e...StartDate - 1):Starting Balanceis set to the summed amount.Net Changeis adjusted:Net Change := (Balance at EndDate) - (Balance at StartDate - 1).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'sTotalingrange. This is required since the query will only return entries for Posting type accountsAnd 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