Fix #11377: Prevent invalid FatturaPA CAP values - #11660
Marco Antonio Mauro (marcus905) wants to merge 5 commits into
Conversation
Good Sense Reviewer - Round 1Recommendation: Accept with SuggestionsWhat this PR doesThis change prevents domestic FatturaPA documents from using a CAP that is not exactly five numeric characters. It validates both the company and customer Post Code before export while preserving the existing The validation matches the exporter’s domestic-address condition and runs through the existing error-message flow before XML generation. The shared helper correctly rejects values with the wrong length or nonnumeric characters, and the existing valid domestic and foreign behaviors remain unchanged. Problem-solution fitFit: Strong The change directly prevents malformed domestic CAP values from reaching the generated XML. Its scope is limited to FatturaPA validation and does not restrict the general-purpose Post Code fields. SuggestionsS1 (🟠 Moderate): Cover invalid company CAP validation Risk assessment and necessityRisk: The production change is limited to pre-export validation in Necessity: The validation is required because malformed domestic CAP values otherwise produce schema-invalid FatturaPA XML. The scope is appropriate and uses the existing validation mechanism.
|
What & why
The Italian FatturaPA exporter writes the Business Central
Post Codedirectly to theCAPelement for domestic addresses.FatturaPA requires
CAPto contain exactly five numeric characters, while the standard Business CentralPost Codefield is intentionally more general and is not restricted to that format. This means values such as1234Acan currently be accepted by Business Central and then emitted as schema-invalid FatturaPA XML.This change adds FatturaPA-specific validation without changing the general-purpose
Post Codefield.The change:
Post Codebefore generating a FatturaPA document;Post Codewhen the customer is domestic;CAPvalues to contain exactly five numeric characters;00000instead of the foreign postal code;Linked work
Fixes #11377
How I validated this
What I tested and the outcome
Added regression coverage in
FatturaPATest.Codeunit.alfor a domestic customer with an invalid CAP such as1234A.The test verifies that FatturaPA validation reports the invalid customer
Post Codeand 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
Post Codefield remains unrestricted for normal Business Central use and international addresses. The five-digit numeric constraint is applied only by the FatturaPA validation logic when the value will be used as a domesticCAP.Foreign-customer behavior is unchanged: the exporter continues to emit
00000for the FatturaPACAPelement.The XML serialization itself is unchanged for valid domestic post codes.