Fix #11371: Prevent invalid FatturaPA RegimeFiscale values - #11633
Marco Antonio Mauro (marcus905) wants to merge 39 commits into
Conversation
Good Sense Reviewer - Round 1Recommendation: AcceptWhat this PR doesThis change makes the Italian FatturaPA fiscal regime a fixed setup catalog, uses that catalog for company setup, and validates the value again before export. The approach addresses both the setup problem and the export backstop while keeping the stored field and existing object IDs stable. Problem-solution fitFit: Strong The reported problem is that invalid fiscal-regime values can reach the generated XML. The change prevents invalid selection, restores the standard catalog during setup and upgrade, and still blocks legacy or bypassed invalid values during validation. SuggestionsNo suggestions. Risk assessment and necessityRisk: The change affects Italian FatturaPA setup, upgrade initialization, and document validation. Compatibility risk is limited because the existing table, field, and object IDs remain in place, and non-standard legacy rows are not deleted. Necessity: The change is necessary because the exporter must not generate fiscal-regime values outside the allowed set. The scope is appropriate because it fixes setup clarity, seeds supported values, and validates again before XML generation.
|
What & why
The Italian FatturaPA exporter builds
RegimeFiscaleby prefixingCompany Information."Company Type"withRF, but the current company type setup allows values that are not valid FatturaPA fiscal regimes. This can result in invalid XML such asRF99.This change makes the existing company type model explicitly represent the FatturaPA fiscal regime while preserving the existing field, table, and object IDs for compatibility.
The change:
Company Information."Company Type"as FatturaPA Fiscal Regime;"Company Types"table as a fixed, read-only catalog of the supported01-19FatturaPA fiscal regimes;19is exported asRF19;Linked work
Fixes #11371
How I validated this
What I tested and the outcome
Added regression coverage in
FatturaPATest.Codeunit.alfor the following scenarios:01through19);99are rejected;19is exported asRF19;Company Information."Company Type"is detected during FatturaPA validation and cannot generate invalidRegimeFiscaleXML.The test library was also updated to select values from the standard fiscal-regime catalog instead of creating arbitrary company type codes.
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 pre-existing test baseline.Risk & compatibility
The existing
Company Information."Company Type"field remainsCode[2], and the existing"Company Types"table, field IDs, and object IDs are retained, so no field-type or data-schema migration is introduced.The
"Company Types"table now represents fixed FatturaPA reference data rather than user-defined setup data. Standard01-19entries are initialized for new companies and during upgrade for existing companies.Existing non-standard rows are not deleted during upgrade to avoid destructive data changes. They are excluded from the normal lookup, cannot be selected as a valid FatturaPA fiscal regime, and are rejected by FatturaPA validation if referenced by legacy or bypassed data.
The exporter itself retains its existing
RF+ fiscal-regime-code serialization once the value has passed validation.