Electronic Invoice — User Guide

Electronic Invoice makes Italian e-invoicing part of the document you are already working on. It generates a compliant FatturaPA XML from your posted sales and purchase documents, builds reverse-charge self-invoices out of your VAT entries, and turns the XML invoices your suppliers send you into ready-to-post purchase documents.

The app covers the three directions of the cycle:

  • outbound — sales invoices and credit memos become XML files and are handed to your SDI intermediary;
  • self-invoices — reverse-charge purchases (TD16–TD19) generate the sales-side XML automatically, in the original currency;
  • inbound — supplier XML files are read, staged, checked and converted into purchase invoices or credit memos.

The app builds the file and passes it to the transmission codeunit you configure. The connection to SDI itself is provided by your intermediary's connector app — see section 1.

The field and button names below are those shown when the English language is active.

1. Set it up once

Page: Electronic Document Format

Business Central already uses this page to know which codeunit builds a FatturaPA file and which one sends it. The app adds two more:

  • Codeunit ID — builds the XML (standard).
  • Delivery Codeunit ID — sends the file to your intermediary (standard). This is what Send to SDI runs.
  • Download Codeunit ID — retrieves the delivery notifications of the files you sent.
  • Import Codeunit ID — retrieves the electronic invoices your suppliers sent you.

The last three come from your intermediary's connector app. Without them the app still generates and downloads files, but Send to SDI and Import From Service have nothing to call.

Page: Sales & Receivables Setup

  • Fattura PA Electronic Format — must point to the format code you configured above. Everything the app does starts from this field.
  • Validate Document On Posting — turn it on to have documents checked automatically before posting (see section 5).

Page: Company Information

Fill the fiscal identification fields, and pay particular attention to Liquidation Status: the export refuses to build a file while it is blank, because the value is mandatory in the XML.

Page: Fattura Document Type List

The list of TD codes (TD01, TD04, TD16 … TD27). The app replaces the standard Self-Billing column with its own, which it keeps aligned with the standard one. Tick Self-Billing on every code you want to be usable on a purchase document — typically TD16, TD17, TD18, TD19 and TD20. A code that is not ticked cannot be selected on a purchase document.

2. Prepare your master data

The XML is only as good as the data behind it. Before the first send, check:

  • Payment Method Code on customers and vendors, and the Fattura PA Payment Method on each payment method (MP01, MP05, …).
  • Payment Terms Code, and the Fattura Payment Terms Code on each payment term (TP01, TP02, …).
  • PA Code on customers that are public administrations — it also drives the automatic validation on posting.
  • VAT Registration No. and Fiscal Code on vendors: this is how an incoming XML is matched to an existing vendor.
  • Company Type on the Vendor Card — added by the app for the fiscal classification of the supplier.
  • A Configuration Template for the Vendor table, used to complete a vendor the app has to create from an incoming file (see section 9).

3. Send a posted sales invoice to SDI

Page: Posted Sales Invoice / Posted Sales Credit Memo (cards and lists)

Three actions are added to the ribbon:

  • Generate XML File — builds the file and downloads it to your PC, so you can inspect it or send it manually.
  • Send to SDI — builds the file and hands it to the delivery codeunit.
  • Reset File Name — clears the file name so the document can be generated again.

What happens: the generated file name is stored on the document in Elect. Inv. File Name, in the form IT<your VAT number>_<progressive>.xml. That field is the app's record that the document has been processed: as long as it is filled, you can see at a glance which documents have already been sent.

If you need to rebuild a file — because you corrected something, or because the transmission failed — press Reset File Name first, then generate again.

4. What the app adds to the XML

Beyond the standard FatturaPA content, the file carries:

  • Attachments — every Document Attachment linked to the document is embedded in the XML as <Allegati>, so the PDF travels with the invoice.
  • Intent declarations — the Dichiarazione d'Intento number, protocol and date are written as AltriDatiGestionali on the exempt lines.
  • Order and delivery referencesCustomer Purchase Order No. and the Customer Purchase Order Date field the app adds to the Sales Order, plus shipment (DDT) references.
  • Bank receipt (RiBa) — when the payment is a bank receipt, the IBAN written in the payment block is the one of the collecting bank account.
  • XML Document Reason — a free text field added to sales and purchase documents, exported as the <Causale> element. On self-invoices in foreign currency it is filled automatically (see section 6).

Characters that FatturaPA does not accept are normalised automatically, and telephone numbers are checked against the 5–12 digit rule before the file is built.

5. Check documents before you post

Page: Sales & Receivables SetupValidate Document On Posting

With the option on, every sales document is checked as part of posting, and every purchase document destined to become a self-invoice is checked too.

What is checked: company information, the FatturaPA number series, the payment method and its Fattura PA code, the payment terms and their Fattura code, and — on purchases — that the Vendor Cr. Memo No. does not exceed 20 characters, which is a frequent cause of rejection.

What happens: the problems are collected and shown together in the standard Error Messages page, instead of stopping at the first one. Fix them all in one pass and post again.

6. Self-invoices for reverse charge

When you post a purchase with reverse charge, Business Central creates both purchase and sales VAT entries. The sales side is the self-invoice you owe to SDI, and the app builds it for you.

Page: Purchase Invoice / Purchase Credit Memo

  1. Set Fattura Document Type on the purchase document — only codes flagged as self-billing can be chosen (see section 1). The value is checked again when you release the document, so a wrong code cannot reach posting.
  2. Post the document. The app finds the sales VAT entries generated by the reverse charge and writes their document number into Sales Document No. on the posted purchase invoice.
  3. Open the Posted Purchase Invoice and press Generate XML File or Send to SDI, exactly as for a sales document.

What happens: the self-invoice is built from the VAT entries themselves — one XML line per VAT identifier — so the amounts always agree with what was actually posted. The SDI Id field carries the identifier of the original supplier invoice when the code you use requires it (TD16).

Documents in foreign currency. The VAT entries only hold local-currency amounts, which is not enough for the file. For each line the app sums the base amounts of the purchase lines sharing the same VAT identifier and writes an AltriDatiGestionali block with the currency code, the original amount and the document date. The header XML Document Reason is filled automatically with the document total in the original currency and the exchange factor used. Amounts are computed from the original line values rather than from the currency factor, so no rounding drift is introduced.

If you want a different wording in <Causale>, type it into XML Document Reason before generating: the automatic text is only written when the field is empty.

7. Correct a document after posting

Some of the data the XML needs is discovered after posting. The app extends the standard update pages so it can still be corrected:

  • Posted Purchase Invoice - UpdateFattura Document Type, XML Document Reason
  • Posted Purchase Credit Memo - UpdateVendor Cr. Memo No.
  • Posted Sales Shipment - UpdateCustomer Purchase Order No.

Change the value, confirm, then generate the file again (remember Reset File Name if one was already produced).

Copying a document never carries e-invoicing data across: file name, Fattura document type, SDI Id and customer purchase order date are cleared on the copy, so a new document is never mistaken for one already sent.

8. Receive supplier invoices

Page: XML Invoice List

This is the inbox of everything that arrived from your suppliers. One row per XML file:

  • Created At, File Name, Name (the supplier), Invoice No., Invoice Date, Reception Date
  • NAV Invoice No. — the Business Central document created from the file
  • Posted — ticked once that document has been posted
  • Error Message — shown in red when something went wrong; rows with errors are sorted to the top

Actions:

  • Import From Service — runs the download and import codeunits of your intermediary and loads whatever is waiting.
  • Import File — loads a single XML from your PC, for the files that arrive by other routes.
  • Detail — opens the parsed content of the file (see below).
  • Download File — saves the original XML back to your PC.
  • Validate / Undo Validate — see section 9.

Page: XML Invoice Lines

The Detail action shows exactly what the app read out of the file, as name/value pairs grouped in sections: fornitore (supplier), cliente (your company), testata (document header), contratto (contract references), pagamenti (payment schedule) and righe (lines). Nothing is hidden — when a value did not end up where you expected on the purchase invoice, this page tells you whether it was missing from the file or lost in the mapping.

9. Turn a supplier XML into a purchase invoice

Page: XML Invoice ListValidate

Action: select a row and press Validate, then confirm.

What happens: the app creates a Purchase Invoice — or a Purchase Credit Memo when the document type in the file is TD04 — and fills it:

  • Vendor — searched by VAT registration number and fiscal code, then by VAT number with the country prefix. If no vendor matches, one is created from the file's registry data and completed from the Vendor configuration template (the template whose code matches the country, or the first available one).
  • Dates — when your intermediary supplies a reception date, it is used for posting date, invoice received date, operation occurred date and VAT reporting date; otherwise the document date from the file is used.
  • Vendor Invoice No., Currency Code (only when the file is not in EUR) and Check Total from the document total.
  • Payment Method — matched on the Fattura PA Payment Method code found in the file.
  • Payment Lines — one per instalment in the file, converted into percentages of the document total, with the last one adjusted so the schedule always reaches 100%.
  • Lines — one per DettaglioLinee, with description (split over Description and Description 2 when longer than 50 characters), unit of measure, VAT %, quantity and direct unit cost. The item or account behind each line comes from the mapping described in section 10.

Review the draft, correct what needs correcting, and post it as any other purchase invoice. Once posted, the XML Invoice List row shows NAV Invoice No. and Posted.

Undo Validate deletes the draft document and returns the row to the not-validated state, so you can fix a mapping and try again. It only works while the document has not been posted.

10. Map supplier products to your items

Page: Item Vendor Mapping

One line per supplier code you want to recognise:

  • Vendor No. — the supplier the rule applies to
  • Vendor Item No. — the code (or description) as the supplier writes it
  • Type / No. — what it becomes in your document: G/L Account, Item, Resource, Fixed Asset, Item Charge or Standard Text

Resolution order. For each line of the file the app looks for a value to match, first the supplier's own item code, then the SKU, then the description. It then tries, in order:

  1. an exact match on Vendor Item No. for that vendor;
  2. a prefix match — a mapping line whose code is the beginning of the value found in the file;
  3. the vendor default — a line for that vendor with a blank Vendor Item No.;
  4. the global default — a line with a blank Vendor No. and a blank Vendor Item No.

Create the global default row first: it is the safety net that lets any file be imported, typically pointing to a costs G/L account you review manually. Then add specific rules for the suppliers whose invoices you receive most often.

11. Run it automatically

Page: Job Queue Entries

Create one entry that runs Codeunit 18161915 — PTG EI Scheduler on the recurrence you want (nightly is typical).

What happens: the entry runs the download codeunit — collecting the delivery notifications of the files you sent — and then the import codeunit, loading the new supplier invoices into the XML Invoice List. Your team arrives to a populated inbox and only has to review and validate.

Good to know

  • The file name is the "already sent" flag. Nothing is sent twice while Elect. Inv. File Name is filled. Reset File Name is the deliberate way to override that.
  • Create the global fallback row in Item Vendor Mapping before your first import. Without a mapping line that matches everything, a file containing an unrecognised product cannot be validated.
  • Self-invoice amounts always come from the VAT entries, never from the purchase lines, so the XML total always agrees with your VAT ledger. Foreign-currency detail is added on top, it does not replace them.
  • <Causale> is yours to control. Type your own text in XML Document Reason and the app leaves it alone; leave it empty on a foreign-currency self-invoice and the app fills it.
  • Errors are stored, not thrown away. A file that could not be parsed still creates a row in the XML Invoice List with the reason in Error Message — nothing arrives silently and disappears.
  • Attachments follow the invoice. Anything attached to the document through Document Attachment ends up inside the XML, so there is no separate mail to send.
  • A vendor created from a file is a real vendor. Review it once — posting groups, payment terms, dimensions — because the configuration template only fills what you told it to fill.