pt-saft-v1
Module: github.com/invopop/gobl.pt.saft
Portugal doesn’t have an e-invoicing format per se. Tax information is reported
electronically to the AT (Autoridade Tributária e Aduaneira) either periodically in
batches via a SAF-T (PT) report or individually in real time via a web service. This addon
ensures that the GOBL documents have all the required fields to be able to be reported to
the AT.
Sources
- Portaria n.o 302/2016 – SAF-T Data Structure & Taxonomies
- Portaria n.o 195/2020 – Comunicação de Séries Documentais, Aspetos Específicos
- Portaria n.o 195/2020 – Especificações Técnicas Código QR
- Comunicação dos elementos dos documentos de faturação à AT, por webservice
Correction Definitions
Auto-generation of corrective invoices or credit and debit notes is supported. A reason is required in thereason field
when submitting the correction options.
Scenarios
bill/invoice
standard
standard
Filters:
- Types:
standard
- Extensions:
pt-saft-invoice-type:FT
standard, #simplified
standard, #simplified
Filters:
- Types:
standard - Tags:
simplified
- Extensions:
pt-saft-invoice-type:FS
standard
standard
Filters:
- Types:
standard - Filter: (custom)
- Extensions:
pt-saft-invoice-type:FR
debit-note
debit-note
Filters:
- Types:
debit-note
- Extensions:
pt-saft-invoice-type:ND
credit-note
credit-note
Filters:
- Types:
credit-note
- Extensions:
pt-saft-invoice-type:NC
proforma
proforma
Filters:
- Types:
proforma
- Extensions:
pt-saft-work-type:PF
Extensions
Invoice Type
SAF-T’sInvoiceType (Tipo de documento) specifies the type of a sales invoice. In GOBL,
this type can be set using the pt-saft-invoice-type extension in the tax section. GOBL
will set the extension for you based on the type and the tax tags you set in your invoice.
The table below shows how this mapping is done:
Example:
pt-saft-invoice-type
pt-saft-invoice-type
Payment Type
To report payment receipts to the AT, GOBL provides conversion frombill.Payment
documents. In a payment, the SAF-T’s PaymentType (Tipo de documento) field specifies its
type. In GOBL, this type can be set using the pt-saft-payment-type extension. GOBL will
set the extension automatically based on the type and the tax tags you set. The table
below shows how this mapping is done:
For example:
pt-saft-payment-type
pt-saft-payment-type
Tax Rate Code
The SAF-T’sTaxCode (Código do imposto) is required for invoice items that apply VAT.
GOBL provides the pt-saft-tax-rate extension to set this code at line tax level. It also
determines it automatically this code using the rate field (when present). The following
table lists the supported tax codes and how GOBL will map them:
pt-saft-tax-rate
pt-saft-tax-rate
Tax exemption reason code
The SAF-T’sTaxExemptionCode (Código do motivo de isenção de imposto) is a code that
specifies the reason the VAT tax is exempt in a Portuguese invoice. When the exempt tag
is used in a tax combo, the ext map’s pt-saft-exemption property is required.
The SAF-T’s TaxExemptionReason (Motivo da isenção de imposto) is a text that justifies
the exemption referencing the relevant legislation. In GOBL, this is provided with a
special line-level note.
By default, if no note is provided, GOBL will automatically assign a default one
consistent with the exemption code. However, note that default texts are generic and not
always sufficiently precise to comply with the regulations. The invoice issuer should be
given the option to provide a custom note with the appropriate descriptive text.
For example, you could define an invoice line exempt of tax with the exemption code and
the reason as follows:
pt-saft-exemption
pt-saft-exemption
Product Type
SAF-T’sProductType (Indicador de produto ou serviço) indicates the type of each line
item in an invoice. The pt-saft-product-type extension used at line item level allows to
set the product type to one of the allowed values.
Example:
pt-saft-product-type
pt-saft-product-type
Document Type
SAF-T’sWorkType (Tipo de documento de conferência) specifies the type of a working
document. In GOBL, this type can be set using the pt-saft-work-type extension in either
bill.Invoice or bill.Order documents. GOBL will set the extension for you based on the
document type in some cases.
The table below shows the supported work type codes and their compatibility with GOBL objects:
Example for a proforma invoice:
pt-saft-work-type
pt-saft-work-type
Payment Means
The SAF-T’sPaymentMechanism (Meios de pagamento) field specifies the payment means in a
sales invoice or payment. GOBL provides the pt-saft-payment-means extension to set this
value in your bill.Invoice advances or in your bill.Payment method. GOBL maps certain
payment mean keys automatically to this extension:
(*) For codes not mapped from a GOBL Payment Mean, use
other and explicitly set the
extension.
For example, in a GOBL invoice:
pt-saft-payment-means
pt-saft-payment-means
Document Source
SAF-T’sSourceBilling (Origem do documento) field specifies the source of the document.
GOBL provides the pt-saft-source extension to set this value in your documents.
By default, GOBL will set this extension to “P” (Produced).
The table below shows the supported source billing codes:
Example:
pt-saft-source
pt-saft-source
Source Document Reference
GOBL provides thept-saft-source-ref extension to provide the full reference to a document
integrated from another system, recovered or issued manually.
This extension is required when the document source (pt-saft-source extension) is
“M” (manual) or “I” (integrated). It must contain the complete document reference to be appended
to the SAF-T’s HashControl field as stipulated by Despacho n.o 8632/2014.
Example with a manual document:
pt-saft-source-ref
pt-saft-source-ref
Movement Type
SAF-T’sMovementType (Tipo de documento de movimentação de mercadorias) specifies the type of
a delivery document. In GOBL, this type can be set using the pt-saft-movement-type extension.
If not provided explicitly, GOBL will set the extension for you based on the type and tags of
your delivery document.
The table below shows how this mapping is done:
(*) or codes not mapped from a GOBL type or tag; use
other as the delivery type and explicitly set the
extension.
For example, to indicate a return delivery (GD):
pt-saft-movement-type
pt-saft-movement-type
Validation Rules
bill.Invoice
bill.Invoice
bill.Payment
bill.Payment
bill.Delivery
bill.Delivery
bill.Order
bill.Order
tax.Combo
tax.Combo
tax.RateTotal
tax.RateTotal
org.Item
org.Item
org.Note
org.Note
bill.Line
bill.Line
bill.PaymentLine
bill.PaymentLine