[Bug]: FatturaPA filename does not fall back to VAT Registration No. when Fiscal Code is empty
Nobody has claimed this yet.
- Dominant language
- AL
- Stars
- 683
- Forks
- 459
- Avg merge
- 3d 26m
- Merged PRs (30d)
- 633
Description
Describe the issue
In the Italian localization, the FatturaPA transport filename generated by codeunit "Fattura Doc. Helper" is inconsistent with the transmitter identifier written to the generated FatturaPA XML when the company's Fiscal Code is empty.
Fattura Doc. Helper.GetFileName() currently builds the filename as:
CompanyInformation."Country/Region Code" +
CompanyInformation."Fiscal Code" + '_' +
ZeroNo + BaseString
The method itself documents the expected structure as:
country code + transmitter's unique identity code + unique progressive number of the file
However, when generating DatiTrasmissione/IdTrasmittente/IdCodice, "Export FatturaPA Document" already uses the following logic:
if CompanyInformation."Fiscal Code" = '' then
TempXMLBuffer.AddNonEmptyLastElement(
'IdCodice', CompanyInformation."VAT Registration No.")
else
TempXMLBuffer.AddNonEmptyLastElement(
'IdCodice', CompanyInformation."Fiscal Code");
Therefore, when Fiscal Code is empty and VAT Registration No. is populated, Business Central can generate an XML containing a valid transmitter identifier while producing a transport filename without that identifier.
For example, with:
Country/Region Code: IT
Fiscal Code:
VAT Registration No.: 01234567890
Progressive No.: 123
the XML contains:
<IdTrasmittente>
<IdPaese>IT</IdPaese>
<IdCodice>01234567890</IdCodice>
</IdTrasmittente>
while the generated filename is effectively:
IT_0000000123.xml
instead of:
IT01234567890_0000000123.xml
The same issue affects the corresponding ZIP filename because the FatturaPA export code uses FatturaDocHelper.GetFileName() as its base name for both XML and ZIP output.
This also means that populating Company Information."Fiscal Code" solely as a workaround for filename generation is undesirable: the XML generator intentionally supports using the VAT Registration No. as IdTrasmittente/IdCodice when Fiscal Code is not set.
Expected behavior
The transmitter identifier used in the FatturaPA transport filename should follow the same selection logic as DatiTrasmissione/IdTrasmittente/IdCodice:
- use
Company Information."Fiscal Code"when it is populated; - otherwise use
Company Information."VAT Registration No.".
In other words, the identifier represented in the transport filename and the identifier represented by IdTrasmittente/IdCodice should remain consistent.
A possible implementation would be to centralize this selection in a helper procedure and use it both for XML generation and filename generation, avoiding duplicated logic.
Conceptually:
local procedure GetTransmitterId(): Text
begin
if CompanyInformation."Fiscal Code" <> '' then
exit(CompanyInformation."Fiscal Code");
exit(CompanyInformation."VAT Registration No.");
end;
and then use the resulting identifier from GetFileName() as well as when populating IdTrasmittente/IdCodice.
Steps to reproduce
-
Use the Italian localization.
-
Open Company Information.
-
Set:
Country/Region Code=ITVAT Registration No.to a valid Italian VAT registration number- leave
Fiscal Codeempty.
-
Configure FatturaPA and its progressive number series normally.
-
Generate/export a FatturaPA document.
-
Inspect
DatiTrasmissione/IdTrasmittentein the generated XML. -
Compare
IdCodicewith the generated XML/ZIP filename.
Actual result
IdTrasmittente/IdCodice falls back to VAT Registration No., while the filename is generated using the empty Fiscal Code, resulting in a name such as:
IT_0000000123.xml
Expected result
The same transmitter identifier should be used in both places, resulting in:
IT01234567890_0000000123.xml
and, where applicable:
IT01234567890_0000000123.zip
Additional context
The inconsistency is currently visible directly in the BaseApp implementation:
Fattura Doc. Helper.GetFileName()always usesCompanyInformation."Fiscal Code"for the transmitter part of the filename.Export FatturaPA Documentalready falls back fromFiscal CodetoVAT Registration No.when generatingIdTrasmittente/IdCodice.
This appears to be a small localization bug rather than a request for configurable file naming: FatturaPA transport filenames have protocol significance and should continue to be generated by the localization. The proposed change only aligns the filename transmitter identifier with the transmitter identifier that Business Central already writes to the XML.
I am willing to provide a fix once the issue is approved for contribution.
I will provide a fix for a bug
- I will provide a fix for a bug
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading Fattura Doc. Helper.GetFileName() and the IdTrasmittente/IdCodice logic in Export FatturaPA Document. Trace how the transmitter identifier reaches XML, XML filenames, and ZIP filenames. Done means Fiscal Code is preferred, VAT Registration No. is used when it is empty, and all output names match the XML identifier.
Written by the indexing model from the issue text.
Assessment
- Domain
- backend, localization
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100