Fix #11389: Prevent invalid FatturaPA Provincia values - #11661
Marco Antonio Mauro (marcus905) wants to merge 4 commits into
Conversation
Good Sense Reviewer - Round 1Recommendation: Accept with SuggestionsWhat this PR doesThis change adds FatturaPA-specific validation for nonblank company The validation correctly requires exactly two uppercase alphabetic characters and reports invalid values through the existing error-message flow. Blank values remain allowed, valid province codes are unchanged, and foreign-customer behavior remains outside the validation as intended. Problem-solution fitFit: Strong The change directly prevents the reported domestic scenario from generating schema-invalid FatturaPA XML without restricting the general-purpose SuggestionsS1 (🟠 Moderate): Cover every new Provincia validation rule Risk assessment and necessityRisk: The change is limited to FatturaPA pre-export validation. Valid two-letter province codes and blank optional values remain accepted, and no public API, database schema, or general Necessity: The validation is needed because unrestricted domestic
|
What & why
The Italian FatturaPA exporter writes the Business Central
Countyfield directly to theProvinciaelement.FatturaPA requires
Provinciato contain a two-character uppercase alphabetic Italian province code, while the standard Business CentralCountyfield is a general-purpose address field and can contain values such asMilano.As a result, Business Central can currently generate schema-invalid FatturaPA XML such as:
This change adds FatturaPA-specific validation without restricting the standard
Countyfield globally.The change:
Countyvalue before generating a FatturaPA document;Countyvalue for domestic customers;Provinciavalue to contain exactly two uppercase alphabetic characters;Provinciamay be omitted when the sourceCountyvalue is blank;Linked work
Fixes #11389
How I validated this
What I tested and the outcome
Added regression coverage in
FatturaPATest.Codeunit.alfor a domestic customer with an invalid Provincia value such asMilano.The test verifies that FatturaPA validation reports the invalid customer
Countyvalue and prevents generation of the electronic document.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.
The standard Business Central
Countyfield remains a general-purpose address field and is not globally constrained. The two-character uppercase alphabetic requirement is applied only by the FatturaPA validation logic when the value will be serialized asProvincia.The validation is applied to domestic addresses only. Existing foreign-address behavior is not changed.
The XML serialization itself is unchanged for valid province codes.