Skip to content

NO SAF-T: skip currency export when currency matches LCY code#29959

Open
jeffreybulanadi wants to merge 2 commits intomicrosoft:mainfrom
jeffreybulanadi:fix/26554-no-saft-skip-lcy-currency-export
Open

NO SAF-T: skip currency export when currency matches LCY code#29959
jeffreybulanadi wants to merge 2 commits intomicrosoft:mainfrom
jeffreybulanadi:fix/26554-no-saft-skip-lcy-currency-export

Conversation

@jeffreybulanadi
Copy link
Copy Markdown

@jeffreybulanadi jeffreybulanadi commented Apr 21, 2026

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

  • Added GeneralLedgerSetup.Get() in GetFCYData, called once after the Export Currency Information guard.
  • Added an LCY code guard in each ledger-entry branch (Customer, Vendor, Bank Account): if the retrieved Currency Code equals GeneralLedgerSetup.LCY Code, exit immediately.
  • The LCY guard is placed before CalcFields to avoid an unnecessary database round-trip when it triggers.
  • Applied identically to both GenerateSAFTFile.Codeunit.al (codeunit 10673, SAF-T v1.0) and GenerateSAFT13File.Codeunit.al (codeunit 10692, SAF-T v1.3).

Related Issue

Fixes #26554

Fixes AB#632882

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 jeffreybulanadi requested a review from a team as a code owner April 21, 2026 15:08
@JesperSchulz JesperSchulz added Finance GitHub request for Finance area linked Issue is linked to a Azure Boards work item labels Apr 24, 2026
@JesperSchulz
Copy link
Copy Markdown
Contributor

@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).
@jeffreybulanadi
Copy link
Copy Markdown
Author

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

  • VendLCYCurrencyCodeNotExportedInCurrencyBlock
  • CustLCYCurrencyCodeNotExportedInCurrencyBlock
  • BankLCYCurrencyCodeNotExportedInCurrencyBlock

SAFTXMLTests13.Codeunit.al (v1.3):

  • VendLCYCurrencyCodeNotExportedInCurrencyBlock
  • CustLCYCurrencyCodeNotExportedInCurrencyBlock
  • BankLCYCurrencyCodeNotExportedInCurrencyBlock

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.

@jeffreybulanadi jeffreybulanadi changed the title fix(NO/SAF-T): skip currency info export when currency equals LCY code NO SAF-T: skip currency export when currency matches LCY code Apr 30, 2026
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 linked Issue is linked to a Azure Boards work item

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Norwegian SAF-T file repeats the same amount when Entry has a Currency Code

3 participants