it-sdi-v1
Module: github.com/invopop/gobl.it.sdi
Italy exchanges electronic invoices in the FatturaPA XML format through the tax
authority’s Sistema di Interscambio (SDI). This addon ensures a GOBL document has
the fields and extensions needed to produce a valid FatturaPA file with
gobl.fatturapa.
Customer identification
Every customer needs atax_id, and what you put in it depends on who they are. For
an Italian business, use their partita IVA (VAT number). An Italian private
individual has no VAT number, so give the country alone and put their codice
fiscale in an identity with the key it-fiscal-code. For a customer outside Italy,
give the country, and their VAT number if they have one.
In your GOBL document you can declare two kinds of inbox to tell SDI where the
invoice should be delivered: it-sdi-code for a codice destinatario, and
it-sdi-pec for a PEC address, which goes in the inbox’s email field. You can
declare both. A FatturaPA document supports only one destination field, so the
conversion prioritises the codice destinatario when it is available, and omits the
PEC.
FatturaPA always asks for a recipient code, and for a tax number when the party is
a business. Some customers have neither, so the format defines a fixed value for
each case and the conversion writes it for you.
A codice destinatario names a channel accredited with SDI, so only recipients in
Italy have one. An Italian customer who receives by PEC, or who has not given you
a code, gets 0000000. A customer outside Italy has none, and SDI cannot deliver
there anyway, so they get XXXXXXX. The conversion takes it from the country, and
any inbox on that customer makes no difference.
The tax number follows the same idea. A party outside Italy with no VAT number
gets 0000000. A business outside the EU has a tax number, but SDI can only check
EU VAT numbers, so the conversion replaces it with OO99999999999, on suppliers
as much as customers. An Italian private individual needs no placeholder: their
codice fiscale identifies them, and the conversion writes no tax number for them.
Simplified invoices
Add thesimplified tag to issue a fattura semplificata (format FSM10,
document types TD07, TD08 and TD09). The customer then needs only a partita
IVA or codice fiscale; a name is sent only together with an address. The total may
not exceed 400.00 EUR unless the supplier is in regime RF19 or RF20 or it is a
credit or debit note correcting a preceding invoice, and every charge and discount
needs a VAT combo,
since the format lists them as entries alongside the lines. A credit or debit note
must identify the invoice it corrects, with its date and the reason. Simplified invoices
cannot go to a public administration, carry retained taxes or fund contributions,
or cover intra-EU supplies (art. 21-bis DPR 633/72). Sales to a habitual exporter
(N3.5) and stamp duty exemptions (NB1, NB2, NB3) need the ordinary format,
the only one that carries the declaration of intent and those codes.
Scenarios
bill/invoice
Private Invoice
Private Invoice
- (none)
- Extensions:
it-sdi-format:FPR12
Government Invoice
Government Invoice
- Tags:
b2g
- Extensions:
it-sdi-format:FPA12
Simplified Invoice
Simplified Invoice
- Tags:
simplified
- Extensions:
it-sdi-format:FSM10
Regular Invoice
Regular Invoice
- Types:
standard
- Extensions:
it-sdi-document-type:TD01
Advance or down payment on invoice
Advance or down payment on invoice
- Types:
standard - Tags:
partial
- Extensions:
it-sdi-document-type:TD02
Credit Note
Credit Note
- Types:
credit-note
- Extensions:
it-sdi-document-type:TD04
Debit Note
Debit Note
- Types:
debit-note
- Extensions:
it-sdi-document-type:TD05
Freelancer invoice with retained taxes
Freelancer invoice with retained taxes
- Types:
standard - Tags:
freelance
- Extensions:
it-sdi-document-type:TD06
Advance or down payment on freelance invoice
Advance or down payment on freelance invoice
- Types:
standard - Tags:
partial,freelance
- Extensions:
it-sdi-document-type:TD03
Simplified Invoice
Simplified Invoice
- Types:
standard - Tags:
simplified
- Extensions:
it-sdi-document-type:TD07
Simplified Credit Note
Simplified Credit Note
- Types:
credit-note - Tags:
simplified
- Extensions:
it-sdi-document-type:TD08
Simplified Debit Note
Simplified Debit Note
- Types:
debit-note - Tags:
simplified
- Extensions:
it-sdi-document-type:TD09
Self-billed for self consumption or for free transfer without recourse
Self-billed for self consumption or for free transfer without recourse
- Types:
standard - Tags:
self-billed
- Extensions:
it-sdi-document-type:TD27
Reverse charge
Reverse charge
- Types:
standard - Tags:
self-billed,reverse-charge
- Extensions:
it-sdi-document-type:TD16,it-sdi-issuer-type:CC
Self-billed Import
Self-billed Import
- Types:
standard - Tags:
self-billed,import
- Extensions:
it-sdi-document-type:TD17,it-sdi-issuer-type:CC
Self-billed EU Goods Import
Self-billed EU Goods Import
- Types:
standard - Tags:
self-billed,import,goods-eu
- Extensions:
it-sdi-document-type:TD18,it-sdi-issuer-type:CC
Self-billed Goods Import
Self-billed Goods Import
- Types:
standard - Tags:
self-billed,import,goods
- Extensions:
it-sdi-document-type:TD19,it-sdi-issuer-type:CC
Self-billed Regularization
Self-billed Regularization
- Types:
standard - Tags:
self-billed,regularization
- Extensions:
it-sdi-document-type:TD20,it-sdi-issuer-type:CC
Self-billed invoice when ceiling exceeded
Self-billed invoice when ceiling exceeded
- Types:
standard - Tags:
self-billed,ceiling-exceeded
- Extensions:
it-sdi-document-type:TD21
Self-billed for goods extracted from VAT warehouse
Self-billed for goods extracted from VAT warehouse
- Types:
standard - Tags:
self-billed,goods-extracted
- Extensions:
it-sdi-document-type:TD22,it-sdi-issuer-type:CC
Self-billed for goods extracted from VAT warehouse with VAT payment
Self-billed for goods extracted from VAT warehouse with VAT payment
- Types:
standard - Tags:
self-billed,goods-with-tax
- Extensions:
it-sdi-document-type:TD23,it-sdi-issuer-type:CC
Deferred invoice ex art.21, c.4, lett. a) DPR 633/72
Deferred invoice ex art.21, c.4, lett. a) DPR 633/72
- Types:
standard - Tags:
deferred
- Extensions:
it-sdi-document-type:TD24
Deferred invoice ex art.21, c.4, third period lett. b) DPR 633/72
Deferred invoice ex art.21, c.4, third period lett. b) DPR 633/72
- Types:
standard - Tags:
deferred,third-period
- Extensions:
it-sdi-document-type:TD25
Sale of depreciable assets and for internal transfers (ex art.36 DPR 633/72)
Sale of depreciable assets and for internal transfers (ex art.36 DPR 633/72)
- Types:
standard - Tags:
depreciable-assets
- Extensions:
it-sdi-document-type:TD26
Purchases from San Marino with VAT (paper invoice)
Purchases from San Marino with VAT (paper invoice)
- Types:
standard - Tags:
self-billed,san-marino-paper
- Extensions:
it-sdi-document-type:TD28,it-sdi-issuer-type:CC
Extensions
SDI Transmission Format
Code used to describe the transmission format of the invoice. It is set during calculation from the invoice’s tags: “FPA12” when the invoice carries the “b2g” tag, “FSM10” when it carries the “simplified” tag, and “FPR12” otherwise.it-sdi-format
it-sdi-format
SDI Document Type
Code used to describe the type of document being sent to the SDI. This is used to determine the correct schema to use when validating the document.it-sdi-document-type
it-sdi-document-type
Fiscal Regime Code
it-sdi-fiscal-regime
it-sdi-fiscal-regime
Exemption Code
it-sdi-exempt
it-sdi-exempt
Retained Tax Payment Reason Code
it-sdi-retained
it-sdi-retained
Retained Tax Statutory Rate
Statutory rate of a withholding computed on a reduced taxable base, as printed in AliquotaRitenuta. Italian withholdings often apply to a fraction of the line total, such as the 23% withheld on 50% of an agent’s commission (art. 25-bis DPR 600/1973). GOBL has no taxable base per tax, so the combo’s percent must be the effective rate over the whole line (11.50% in that example) and this extension keeps the statutory one. Set it when the two differ; ImportoRitenuta is still calculated from the percent, and whether the pair is coherent is up to the issuer.it-sdi-retained-rate
it-sdi-retained-rate
^([0-9]{1,2}\.[0-9]{2}|100\.00)$Payment Means
it-sdi-payment-means
it-sdi-payment-means
VAT Liability
it-sdi-vat-liability
it-sdi-vat-liability
Fund Type
it-sdi-fund-type
it-sdi-fund-type
Issuer Type
Says who issued the invoice when it was not the supplier. FatturaPA requires this in theSoggettoEmittente field whenever someone other
than the supplier issues the document (article 21 of DPR 633/1972).
When you name a third party as the ordering issuer, because that party
issues the invoice on the supplier’s behalf, the addon sets TZ.
When your tags select a document the customer issues, the addon sets
CC and replaces any value you gave: TD16 to TD20, TD22, TD23 and TD28.
On these the customer sends the document to SDI and the supplier block
names the seller. TD21 and TD27 stay unset, because there the issuer is
both supplier and customer. For any other invoice the customer issued,
set CC yourself.
A CC invoice cannot also name an ordering issuer, because FatturaPA
keeps TerzoIntermediarioOSoggettoEmittente for a third party acting for
the supplier.
it-sdi-issuer-type
it-sdi-issuer-type
Liquidation State
Indicates whether the company is in liquidation, used in the IscrizioneREA block of a FatturaPA document as the StatoLiquidazione field.it-sdi-liquidation-state
it-sdi-liquidation-state
Shareholder State
Indicates the company’s shareholder configuration, used in the IscrizioneREA block of a FatturaPA document as the SocioUnico field.SDI Notification
Outcome SDI reports for a submitted invoice, recorded on a bill.Status line. RC/NS/MC/AT/DT are the codes SDI emits directly; EC01/EC02 are the recipient responses resolved from a Notifica Esito.it-sdi-notification
it-sdi-notification
Validation Rules
bill.Invoice
bill.Invoice
bill.Charge
bill.Charge
bill.Status
bill.Status
bill.StatusLine
bill.StatusLine
org.Address
org.Address
org.Attribute
org.Attribute
tax.Combo
tax.Combo
pay.Instructions
pay.Instructions
pay.Record
pay.Record
pay.DueDate
pay.DueDate