Fix #11390: Use ISO country codes in FatturaPA export - #11662
Marco Antonio Mauro (marcus905) wants to merge 6 commits into
Conversation
Good Sense Reviewer - Round 1Recommendation: Accept with SuggestionsWhat this PR doesThis change resolves FatturaPA country values through the related Country/Region record and writes its two-character ISO Code. It also reports missing or invalid ISO setup before XML generation. The seven changed XML values address the reported key-versus-ISO mismatch, and the customer regression test exercises the main scenario. One related domestic-country decision still compares record keys, so equivalent records with the same ISO code can still produce foreign-recipient XML behavior. Problem-solution fitFit: Partial The main serialization defect is fixed consistently across the identified XML values. The remaining key-based domestic-country comparisons and incomplete coverage leave related cases unresolved. SuggestionsS1 (🟠 Moderate): Use ISO codes for domestic-country decisions S2 (🟠 Moderate): Update self-billing vendor test setup S3 (🟠 Moderate): Cover the other changed country sources Risk assessment and necessityRisk: The production change is narrow and does not change schemas or public APIs. The main regression surface is FatturaPA and self-billing export when Country/Region keys differ from ISO codes or test data has no ISO Code. Necessity: The change is required because configurable Business Central record keys can produce country values that FatturaPA does not accept. Resolving the ISO Code is the correct approach and avoids requiring tenants to rename existing country records.
|
What & why
The Italian FatturaPA exporter currently writes Business Central
Country/Region Codevalues directly into FatturaPA elements such asIdPaeseandNazione.However,
Country/Region Codeis the primary key of the Business CentralCountry/Regionrecord and is not required to be the ISO 3166-1 alpha-2 code.For example, a tenant can validly configure:
The current exporter can therefore emit:
instead of the FatturaPA-compatible ISO code:
This change resolves FatturaPA country values through the related
Country/Regionrecord and uses itsISO Codeinstead of assuming that the Business Central primary key is already the required ISO value.The change:
Country/Region."ISO Code"when generating FatturaPA country-code elements;Country/Region Codeprimary key and existing address data without requiring tenants to rename their country records.Linked work
Fixes #11390
How I validated this
What I tested and the outcome
Added regression coverage in
FatturaPATest.Codeunit.alfor the following scenarios:ISO Code;IdPaeseandNazione;Existing foreign-customer FatturaPA tests were also updated so their generated Country/Region test data contains a valid ISO code.
The localized Italian Base Application and test applications build successfully.
FatturaPA Testcodeunit 144200 was executed locally:Library - Error Message.LoadErrorMessagesbecause TestPage field ID2074815070is not present on pageError Messages. These failures are unrelated to the changes in this PR and are unchanged from the existing test baseline.Risk & compatibility
No standard field or table schema is changed.
Country/Region Coderemains the Business Central primary key and is not required to be changed to an ISO value. FatturaPA serialization now resolves the correspondingCountry/Region."ISO Code"when a two-character country code is required.Existing tenants that already use ISO alpha-2 values as their Country/Region keys continue to produce the same XML as long as the corresponding
ISO Codeis configured consistently.Country/Region records used by FatturaPA must now contain a valid two-character
ISO Code. Missing or invalid setup is reported before XML generation instead of allowing an invalid country code to be serialized.