FATTURAPA-IT-00311: SdI Error 00311: Invalid CodiceDestinatario (must be 7 uppercase alphanumeric characters or 0000000 with PEC)
This rule validates the Italian 'CodiceDestinatario' (recipient code) within the FatturaPA header. The context XPath selects the CodiceDestinatario element under DatiTrasmissione. The assertion requires the value to match the regular expression ^[A-Z0-9]{7}$, i.e., exactly 7 uppercase alphanumeric characters. This corresponds to the SdI (Sistema di Interscambio) recipient code used for routing e-invoices. The rule is fatal because an invalid code prevents delivery. Note: The official message mentions an exception for '0000000' with PEC, but the raw XPath does not implement that exception; however, '0000000' itself matches the pattern, so it is allowed. The PEC condition is likely enforced elsewhere. The rule ensures compliance with the FatturaPA 1.2 specification for electronic invoicing in Italy.
1. Ensure the CodiceDestinatario value is exactly 7 characters long. 2. Use only uppercase letters (A-Z) and digits (0-9). 3. If the recipient does not have a CodiceDestinatario, use '0000000' and ensure a valid PEC address is provided in the PECDestinatario element (if applicable). 4. Remove any spaces, punctuation, or lowercase characters. 5. Validate the corrected value against the regex ^[A-Z0-9]{7}$ before resubmitting.
Input does not contain a valid OASIS UBL 2.1 <Invoice> or UN/CEFACT <rsm:CrossIndustryInvoice> root element.
fix: Ensure payload is valid UBL 2.1 or CII D16B XML, or drop an uncompressed ZUGFeRD/Factur-X PDF/A-3.