Fix Close Income Statement grouping when no dimensions are selected - #10096
Fix Close Income Statement grouping when no dimensions are selected#10096ventselartur wants to merge 5 commits into
Conversation
…oseIncomeStatementACY
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
| TempEntryNoAmountBuffer."Business Unit Code" := ''; | ||
| TempEntryNoAmountBuffer."Source Currency Code" := "Source Currency Code"; | ||
| TempEntryNoAmountBuffer."Entry No." := GetEntryNo(DimensionBufferID); | ||
| TempEntryNoAmountBuffer."Entry No." := GetEntryNo(DimensionBufferID, TempEntryNoAmountBuffer."Business Unit Code", "Source Currency Code"); |
There was a problem hiding this comment.
Same issue as the W1 report: GetEntryNo can now return a synthetic negative id in place of the real dimension-buffer id whenever a business-unit/dimension combination is shared by multiple source currencies, but the shipped events publishing TempEntryNoAmountBuffer still expose "Entry No." with its old shape. Existing subscribers correlating on this field can misinterpret the synthetic id.
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.31.4
| TempEntryNoAmountBuffer."Business Unit Code" := ''; | ||
| TempEntryNoAmountBuffer."Source Currency Code" := "Source Currency Code"; | ||
| TempEntryNoAmountBuffer."Entry No." := GetEntryNo(DimensionBufferID); | ||
| TempEntryNoAmountBuffer."Entry No." := GetEntryNo(DimensionBufferID, TempEntryNoAmountBuffer."Business Unit Code", "Source Currency Code"); |
There was a problem hiding this comment.
Same issue as the W1 report: GetEntryNo can now return a synthetic negative id in place of the real dimension-buffer id whenever a business-unit/dimension combination is shared by multiple source currencies, but the shipped events publishing TempEntryNoAmountBuffer still expose "Entry No." with its old shape. Existing subscribers correlating on this field can misinterpret the synthetic id.
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.31.4
| TempDimBuf2.DeleteAll(); | ||
| DimBufMgt.RetrieveDimensions(TempEntryNoAmountBuffer."Entry No.", TempDimBuf2); | ||
| DimBufMgt.RetrieveDimensions( | ||
| GetDimensionBufferID(TempEntryNoAmountBuffer."Business Unit Code", TempEntryNoAmountBuffer."Entry No."), TempDimBuf2); |
There was a problem hiding this comment.
The fix repurposes TempEntryNoAmountBuffer."Entry No." as a currency-specific grouping token (via GetEntryNo's new synthetic negative-ID scheme) instead of the original dimension-buffer ID whenever one business-unit/dimension combination is shared by more than one source currency. That buffer is still published unchanged through the existing IntegrationEvents OnGLEntryOnAfterGetRecordOnAfterEntryNoAmountBuf and OnPostDataItemOnAfterGenJnlLineDimUpdated. Existing event subscribers that read "Entry No." to correlate or re-derive the dimension combination can now receive a synthetic negative id that no longer maps 1:1 to a real dimension buffer (only GetDimensionBufferID, a local procedure, can translate it back), silently changing the event contract's semantics without any signature change. Consider exposing the real dimension-buffer id alongside the new grouping key (e.g. via a new event parameter) instead of overloading the existing field, or document the semantic change for extension authors.
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.31.4
| end; | ||
|
|
||
| [Test] | ||
| [HandlerFunctions('MessageHandler,ConfirmHandler,CloseIncomeStatementRequestPageHandler')] |
There was a problem hiding this comment.
The five new Close Income Statement tests added in BE/CZ/DE/IT/W1 all wire the shared ConfirmHandler/MessageHandler, but those handlers always answer Yes or swallow the message text and the tests never verify that the expected dialogs actually fired. A different confirmation or success message could still let these scenarios pass without proving the right UI interactions were consumed.
Knowledge:
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.31.4
| ClearSelectedDimensionsForCloseIncomeStatement(); | ||
|
|
||
| // [GIVEN] Additional Reporting Currency is blank | ||
| GeneralLedgerSetup.Get(); |
There was a problem hiding this comment.
In the new CloseIncomeStatementConsolidatesEntriesPerGLAccountWithoutARC/WithARC tests across BE/CZ/DE/IT/W1, General Ledger Setup."Additional Reporting Currency" is restored only by cleanup code at the end of the test body. Any earlier Assert failure or runtime error exits before that restore runs, leaving ARC changed for subsequent tests and creating order-dependent contamination between test runs.
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.31.4
Why
Report 94 "Close Income Statement" builds an entry buffer keyed by a dimension buffer ID. When no dimensions are selected for the report, that ID is 0 for every entry, so the report fell back to handing out a fresh negative entry number for each posted G/L entry. The result was one closing journal line (or, with an Additional Reporting Currency, one closing G/L entry) per source entry instead of a single consolidated line per account, business unit and source currency. The source currency code was also dropped whenever a group netted to a zero source currency amount, so a consolidated closing line lost the currency it was closed for.
Fixes AB#646076
Fixes AB#646077
Summary
CloseIncomeStatement.Report.al-GetEntryNonow keys the buffer on business unit, dimension combination and source currency, so entries that share those values collapse into one closing line even when no dimensions are selected.GetDimensionBufferIDand a synthetic-ID mapping so a dimension combination reused by several source currencies still resolves back to the real dimension buffer when dimensions are retrieved.AddSourceCurrencyFieldsto always carry the group's source currency code onto the closing line, including when the source currency amount nets to zero.ResetEntryNoGroupingand removed the stale per-runEntryNoreset so grouping state is cleared correctly between account batches.CloseIncomeStatementConsolidatesEntriesPerGLAccountWithoutARCandCloseIncomeStatementConsolidatesEntriesPerGLAccountWithARCinERMFinancialReports.Codeunit.al, plus aClearSelectedDimensionsForCloseIncomeStatementhelper so leftover Selected Dimension records from other tests do not mask the defect.