NO SAF-T: skip currency export when currency matches LCY code#29959
NO SAF-T: skip currency export when currency matches LCY code#29959jeffreybulanadi wants to merge 2 commits into
Conversation
In GetFCYData, when a Customer, Vendor, or Bank Account Ledger Entry has a Currency Code that equals the company LCY code, the export was incorrectly including CurrencyCode, CurrencyAmount, and ExchangeRate XML nodes in the SAF-T output. Add GeneralLedgerSetup.Get() once after the Export Currency Information guard, then bail out early in each ledger-entry branch when the retrieved currency code matches the LCY code. The early exit is placed before CalcFields to avoid an unnecessary database round-trip. Applied identically to both SAF-T v1.0 (codeunit 10673) and SAF-T v1.3 (codeunit 10692). Fixes microsoft#26554
|
@jeffreybulanadi, could you add some tests? Then I'll process 😊 |
…cy block Add automated tests to verify that ledger entries with a currency code equal to the company LCY code do not export currency information (CurrencyCode, CurrencyAmount, ExchangeRate) in the SAF-T XML output when the Export Currency Information option is enabled. Tests cover vendor, customer, and bank account ledger entries for both SAF-T version 1.0 (SAFTXMLTests.Codeunit.al) and version 1.3 (SAFTXMLTests13.Codeunit.al).
|
Hi @JesperSchulz, added automated tests for the LCY currency code fix. Six new test methods added across both SAF-T versions: SAFTXMLTests.Codeunit.al (v1.0):
SAFTXMLTests13.Codeunit.al (v1.3):
Each test mocks a GL entry and the corresponding ledger entry with Currency Code set to the company LCY code (read from GeneralLedgerSetup after SetupSAFT sets it), runs the export with Export Currency Information enabled, and verifies the DebitAmount node contains only n1:Amount with no CurrencyCode, CurrencyAmount, or ExchangeRate child elements. |
|
Processing this PR. The branch is now locked 🔒 Please don't push updates unless otherwise agreed. |
|
@jeffreybulanadi, thanks for the pull request. We usually use a blank currency for LCY. The "LCY Code" is primarily used for other purpose. May i know what is the reason to use the NOK currency code explicitly for this bank account, but not the blank currency? |
|
The solution doesn't seem to be right. We can pick this up again after the repo migration to BCApps, if need be. We're not going to accept this PR here on ALAppExtensions at this point. |
Summary
When exporting SAF-T (both v1.0 and v1.3), if a Bank Account Ledger Entry (or Customer/Vendor Ledger Entry) has a Currency Code that equals the company LCY code, the export was incorrectly writing CurrencyCode, CurrencyAmount, and ExchangeRate XML nodes for what is effectively a domestic currency entry.
The root cause is in GetFCYData: after checking for a blank Currency Code, the function did not check whether the currency equals the LCY code. A bank account explicitly configured with LCY code (e.g. NOK on a Norwegian company) would pass the blank-check and inject spurious currency XML on all G/L entries in the same transaction.
Changes
Related Issue
Fixes #26554
Fixes AB#632882