Skip to content

Render per-row Currency Code in Aged Accounts Receivable/Payable Excel#8423

Open
mynjj wants to merge 4 commits into
mainfrom
bugs/aged-accounts-currency-code
Open

Render per-row Currency Code in Aged Accounts Receivable/Payable Excel#8423
mynjj wants to merge 4 commits into
mainfrom
bugs/aged-accounts-currency-code

Conversation

@mynjj
Copy link
Copy Markdown
Contributor

@mynjj mynjj commented Jun 2, 2026

Summary

The CurrencyCode column in Aged Accounts Receivable Excel (report 4402) and Aged Accounts Payable Excel (report 4403) was bound to a single AgingData-buffer-wide variable (CurrencyCodeDisplayCode) computed once after InsertAgingData. Every row of a given customer/vendor displayed the same currency — the last one inserted into the buffer. Customers/vendors with entries in multiple currencies saw foreign-currency rows mislabeled with the LCY code (or vice versa).

This change:

  • Binds the CurrencyCode column directly to AgingData."Currency Code" so each row renders its own currency.
  • Falls back to G/L Setup's LCY Code at insertion time when the ledger entry's Currency Code is empty.
  • Removes the now-unused CurrencyCodeDisplayCode variable and label.
  • Splits the Aged Accounts tests out of TrialBalanceExcelReports.Codeunit.al into a new dedicated AgedAccountsExcelReports.Codeunit.al (139547), and adds per-row currency rendering tests for both reports.

Fixes AB#637444

Test plan

  • New tests AgedAccountsRecRendersCurrencyCodePerEntry and AgedAccountsPayableRendersCurrencyCodePerEntry cover the multi-currency rendering case
  • Existing Aged Accounts tests continue to pass after relocation

The CurrencyCode column was bound to a single AgingData-buffer-wide variable
(CurrencyCodeDisplayCode) computed once after InsertAgingData, so every row of
a customer/vendor displayed the same currency — the last one inserted. When a
customer/vendor had entries in multiple currencies, foreign-currency rows
showed the LCY code (or vice versa).

Bind the column to AgingData."Currency Code" directly, and fall back to G/L
Setup's LCY Code at insertion time when the ledger entry's Currency Code is
empty.

Fixes AB#637444
CurrencyCodeDisplayCode is a protected variable and cannot be removed,
so assign AgingData."Currency Code" to it after InsertAgingData.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 3, 2026

$\textbf{🟡\ Medium\ Severity\ —\ Performance} \quad \color{gray}{\texttt{\small Iteration\ 1}}$

GeneralLedgerSetup.Get guard inconsistency

A GeneralLedgerSetup.Get() guard is added at report initialization, but the variable is already used later in InsertAgingData via GeneralLedgerSetup.GetCurrencyCode(''). If the Get() fails at initialization (which should not happen in production but could in tests), Clear(GeneralLedgerSetup) will cause GetCurrencyCode('') to call a method on an empty record, potentially returning an unexpected value instead of the LCY code.

Recommendation:

  • If GL Setup is expected to always exist, use GeneralLedgerSetup.Get() without the if not ... then Clear pattern, or handle the error explicitly to surface missing setup as a configuration problem.
GeneralLedgerSetup.Get();

Line mapping was unavailable, so this was posted as an issue comment.

👍 useful · ❤️ especially valuable · 👎 wrong - reply with why

@mynjj mynjj requested review from a team as code owners June 3, 2026 07:16
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