Skip to content

Fix Close Income Statement grouping when no dimensions are selected - #10096

Open
ventselartur wants to merge 5 commits into
mainfrom
bugs/646076-646077-CloseIncomeStatementACY
Open

Fix Close Income Statement grouping when no dimensions are selected#10096
ventselartur wants to merge 5 commits into
mainfrom
bugs/646076-646077-CloseIncomeStatementACY

Conversation

@ventselartur

@ventselartur ventselartur commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

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

  • Fixed entry grouping in CloseIncomeStatement.Report.al - GetEntryNo now 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.
  • Added GetDimensionBufferID and 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.
  • Fixed AddSourceCurrencyFields to always carry the group's source currency code onto the closing line, including when the source currency amount nets to zero.
  • Added ResetEntryNoGrouping and removed the stale per-run EntryNo reset so grouping state is cleared correctly between account batches.
  • Added tests CloseIncomeStatementConsolidatesEntriesPerGLAccountWithoutARC and CloseIncomeStatementConsolidatesEntriesPerGLAccountWithARC in ERMFinancialReports.Codeunit.al, plus a ClearSelectedDimensionsForCloseIncomeStatement helper so leftover Selected Dimension records from other tests do not mask the defect.
  • Propagated the report change to the ES and IT layers and the test changes to the BE, CZ, DE and IT layers via Miapp.

@ventselartur
ventselartur requested a review from a team August 10, 2026 14:12
@github-actions github-actions Bot added the Finance GitHub request for Finance area label Aug 10, 2026
@github-actions github-actions Bot added this to the Version 29.0 milestone Aug 10, 2026
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");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$\textbf{🟡\ Medium\ Severity\ —\ Breaking\ Changes}$

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");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$\textbf{🟡\ Medium\ Severity\ —\ Breaking\ Changes}$

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);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$\textbf{🟡\ Medium\ Severity\ —\ Breaking\ Changes}$

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')]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$\textbf{🟡\ Medium\ Severity\ —\ Testing}$

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();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$\textbf{🟡\ Medium\ Severity\ —\ Testing}$

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Finance GitHub request for Finance area

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant