Skip to content

Fix #11389: Prevent invalid FatturaPA Provincia values - #11661

Open
Marco Antonio Mauro (marcus905) wants to merge 4 commits into
microsoft:mainfrom
marcus905:fix-11389-fatturapa-provincia-validation
Open

Marco Antonio Mauro (marcus905) wants to merge 4 commits into
microsoft:mainfrom
marcus905:fix-11389-fatturapa-provincia-validation

Conversation

@marcus905

@marcus905 Marco Antonio Mauro (marcus905) commented Sep 21, 2026

Copy link
Copy Markdown

What & why

The Italian FatturaPA exporter writes the Business Central County field directly to the Provincia element.

FatturaPA requires Provincia to contain a two-character uppercase alphabetic Italian province code, while the standard Business Central County field is a general-purpose address field and can contain values such as Milano.

As a result, Business Central can currently generate schema-invalid FatturaPA XML such as:

<Provincia>Milano</Provincia>

This change adds FatturaPA-specific validation without restricting the standard County field globally.

The change:

  • validates the company County value before generating a FatturaPA document;
  • validates the customer County value for domestic customers;
  • when populated, requires a FatturaPA Provincia value to contain exactly two uppercase alphabetic characters;
  • preserves the existing behavior where Provincia may be omitted when the source County value is blank;
  • reports invalid values through the existing FatturaPA error-message validation flow rather than allowing schema-invalid XML to be generated.

Linked work

Fixes #11389

How I validated this

  • I read the full diff and it contains only changes I intended.
  • I built the affected app(s) locally with no new analyzer warnings.
  • I ran the change in Business Central and confirmed it behaves as expected.
  • I added or updated tests for the new behavior, or explained below why none are needed.

What I tested and the outcome

Added regression coverage in FatturaPATest.Codeunit.al for a domestic customer with an invalid Provincia value such as Milano.

The test verifies that FatturaPA validation reports the invalid customer County value and prevents generation of the electronic document.

The localized Italian Base Application and test applications build successfully.

FatturaPA Test codeunit 144200 was executed locally:

Risk & compatibility

No standard field or table schema is changed.

The standard Business Central County field 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 as Provincia.

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.

@github-actions github-actions Bot added From Fork Pull request is coming from a fork needs-approval Workflow runs require maintainer approval to start Team: Finance GitHub request for Finance area labels Sep 21, 2026
@alexei-dobriansky

Copy link
Copy Markdown
Contributor

Good Sense Reviewer - Round 1

Recommendation: Accept with Suggestions

What this PR does

This change adds FatturaPA-specific validation for nonblank company County values and domestic customer County values before they are serialized as Provincia.

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 fit

Fit: Strong

The change directly prevents the reported domestic scenario from generating schema-invalid FatturaPA XML without restricting the general-purpose County field globally.

Suggestions

S1 (🟠 Moderate): Cover every new Provincia validation rule
The regression test uses Milano, so it only proves the length check. Add two-character lowercase and non-letter cases, plus an invalid Company Information County, to cover every new validation branch.

Risk assessment and necessity

Risk: 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 County behavior changes.

Necessity: The validation is needed because unrestricted domestic County values can otherwise produce FatturaPA XML that fails schema validation. The implementation is targeted to the fields serialized as Provincia.


[AI-PR-REVIEW] version=1 promptVersion=4 system=github pr=11661 round=1 by=alexei-dobriansky at=2026-09-21T13:36:26Z lastSha=60f232dbac02ec93db9a080891f48bfa0733018b reviewKey=2902f19ce08ebcfaee0933bcb2f454828ce88f6afaef10c1e1d15db179af47c0 suggestions=S1@13c1a476

@github-actions github-actions Bot added needs-approval Workflow runs require maintainer approval to start and removed needs-approval Workflow runs require maintainer approval to start labels Sep 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

From Fork Pull request is coming from a fork needs-approval Workflow runs require maintainer approval to start Team: Finance GitHub request for Finance area

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Italian FatturaPA exporter can generate invalid Provincia values from unconstrained County fields

2 participants