Introduction
Brazil has a variety of electronic tax documents that must be issued in different cases for various tax purposes. These include service invoices (NFS-e), product invoices (NF-e), and consumer invoices (NFC-e). Each document type is subject to variations from state to state and municipality to municipality, with each jurisdiction applying its own rules, formats, and APIs for issuing fiscal documents. Invopop’s Documentos Fiscais Eletrônicos app provides a unified way to issue fiscal documents across all Brazilian states and over 2000 municipalities using GOBL. You can find the full list of supported municipalities here. This guide will walk you through the steps required to issue electronic fiscal documents in a supplier’s name, and to cancel them if needed.Prerequisites
To issue electronic fiscal documents in Brazil, you will need:- A registered supplier: follow the DF-e supplier registration guide to connect the Documentos Fiscais Eletrônicos Brazil app and register the supplier’s certificate before issuing.
- Customer details (except for NFC-e where the customer is optional).
- Details of the goods or services provided:
- quantity,
- price,
- applicable tax rates (ISS, ICMS, PIS, COFINS, etc.), and,
- (only for services) service code (Código Item Lista Serviço) as defined by the municipality.
- To have chosen an invoice series
Setup
Prepare the invoicing workflows for the document types you want to issue and cancel.Prepare NFS-e workflow
DF-e issue service invoice (NFS-e)
- Workflow
- Code
Prepare NF-e Workflow
DF-e issue product invoice (NF-e)
- Workflow
- Code
Prepare NFC-e Workflow
DF-e issue consumer invoice (NFC-e)
- Workflow
- Code
Prepare NFS-e Cancel Workflow
DF-e cancel service invoice (NFS-e)
- Workflow
- Code
Prepare NF-e Cancel Workflow
DF-e cancel product invoice (NF-e)
- Workflow
- Code
Prepare NFC-e Cancel Workflow
DF-e cancel consumer invoice (NFC-e)
- Workflow
- Code
Running
In this section, we’ll provide details on how to issue invoices on behalf of a registered supplier, and how to cancel them. As usual, the recommended approach for running jobs is to perform two steps; first upload the document to the silo, second create a job. All operations described in the following sections can be performed manually via the Invopop Console, or programmatically via the API. The process is essentially the same in both cases, so we’ll demonstrate the manual method for this guide.Send invoices
The following examples are of example GOBL documents you can copy and paste directly into the Invopop Console or store via the API as silo entries. Then, you must run the appropriate issue workflow created during setup — “DF-e issue service invoice (NFS-e)”, “DF-e issue product invoice (NF-e)”, or “DF-e issue consumer invoice (NFC-e)” — over them.Example B2B service invoice (NFS-e)
Example B2B service invoice (NFS-e)
- we’ve added the
br-nfse-v1addon; this ensures the document will be validated using the NFS-e rules built into the GOBL library, - extensions (
ext) and identities have been used in multiple locations for fields whose values cannot be determined any other way, - ISS percentage is provided explicitly as it varies depending on the municipality and type of service,
- there are no totals or calculations; all these will be made automatically when uploading, and,
- make sure to process it with the “DF-e issue service invoice (NFS-e)” workflow created during setup.
Example B2B service invoice with RTC (NFS-e)
Example B2B service invoice with RTC (NFS-e)
- we’ve set the
br-nfse-operationextension, thebr-nfse-tax-statusextension and thebr-nfse-tax-classextension at item level which will be used to determine the IBS and CBS taxes as part of the tax reform.
Example B2B product invoice (NF-e)
Example B2B product invoice (NF-e)
- we’ve added the
br-nfe-v4addon without thesimplifiedtag; this sets thebr-nfe-modelextension to55(NF-e), - the customer is required for NF-e and must include a full address; Brazilian customers must declare the
br-ibge-municipalityextension and a valid state, while foreign customers can be identified by a country-qualifiedidentity(e.g. a passport) instead of atax_id, - supplier and customer addresses must include a
country; it is auto-filled from the party’s tax ID (or first identity that declares a country) when omitted, - each line must include a
br-nfe-cfopextension to classify the fiscal operation, - item identities carry the NCM product classification code (
cProdin the NF-e XML) and the GTIN barcode (cEAN), item.refmaps to the supplier’s internal product code, anditem.unitis converted to a UNECE unit code,- line
discountsreduce the taxable base (vDesc); linechargeswith keydeliverymap to freight (vFrete) and keyinsuranceto insurance value (vSeg), line.orderprovides the line reference within the purchase order (nItemPed),- a line
notesentry with keygoodsmaps to per-item additional information (infAdProd), ordering.codesets the purchase order number (nPedincompra) andordering.contracts[0].codesets the contract number (nCont),delivery.receiversets a separate delivery address (entrega) when goods ship to a different location than the buyer’s fiscal address,- the payment instructions key is set to
credit-transfer, which causes thebr-nfe-payment-meansextension to be set automatically to18(transferência bancária), - a
generalnote maps to complementary information (infCpl) in the NF-e XML, - tax percentages are provided explicitly as they vary depending on the state and type of goods,
- there are no totals or calculations; all these will be made automatically when uploading, and,
- make sure to process it with the “DF-e issue product invoice (NF-e)” workflow created during setup.
Example B2B product invoice for a Simples Nacional issuer (NF-e)
Example B2B product invoice for a Simples Nacional issuer (NF-e)
- the supplier declares its regime with the
br-nfe-regimeextension set to1(Simples Nacional);4(MEI) behaves the same, while2(Simples Nacional, Excess) uses CST codes like the normal regime (3, the default), - each ICMS line carries the
br-nfe-icms-csosnextension (here101, taxed with credit permission) instead of thebr-nfe-icms-cstcode that normal-regime issuers use, - with CSOSN
101the ICMSpercentis not a charged tax: it represents the Simples Nacional credit rate (pCredSNin the NF-e XML) and the resulting amount becomes the credit value the buyer may take (vCredICMSSN), - CSOSN
101transfers a tax credit and is only accepted when the customer is an ICMS taxpayer, so the customer includes abr-nfe-state-regidentity with its state registration number, - PIS and COFINS are still required on every line but are not levied per item under Simples Nacional, so they use the
br-nfe-pis-cstandbr-nfe-cofins-cstextensions set to49(other operations) at a0%rate, - there are no totals or calculations; all these will be made automatically when uploading, and,
- make sure to process it with the “DF-e issue product invoice (NF-e)” workflow created during setup.
Example NF-e for a full goods return
Example NF-e for a full goods return
- the document
typeiscredit-note; it keeps thebr-nfe-v4addon and is still issued as an NF-e, sobr-nfe-modelis derived as55, - a
precedingentry references the original NF-e and carries its SEFAZ access key (chave de acesso) as a stamp — you can copy it from thesefaz-keyentry in thestampsarray of the original invoice’s envelopehead, where it was added once the tax authority authorized the document, - because this is a full return, the
br-nfe-purposeextension is set to4(Goods Return) and thebr-nfe-operation-typeextension to0(Inbound / Entrada), since the returned goods re-enter the supplier; standard invoices set these automatically to1(normal) and1(outbound), but corrective documents must set both explicitly, - no
br-nfe-credit-note-typeextension is used: that field only applies to post-reform IBS/CBS credit notes (those setbr-nfe-purposeto5), - the line
br-nfe-cfopis a return code —2202(Devolução de venda de mercadoria adquirida ou recebida de terceiros) — mirroring the original6102sale but recorded as an inbound inter-state operation (CFOP starting with2), - the payment sets the
br-nfe-payment-meansextension to90(No payment), as a return does not involve a new payment, - there are no totals or calculations; all these will be made automatically when uploading, and,
- make sure to process it with the “DF-e issue product invoice (NF-e)” workflow created during setup.
Example B2C consumer invoice (NFC-e)
Example B2C consumer invoice (NFC-e)
- we’ve added the
br-nfe-v4addon with thesimplifiedtag; this sets thebr-nfe-modelextension to65(NFC-e), - the customer is optional and in this example we’ve omitted it,
- extensions (
ext) and identities have been used in multiple locations for fields whose values cannot be determined any other way, - each line must include a
br-nfe-cfopextension to classify the fiscal operation, just as on an NF-e, - the payment instructions key is set to
card, which causes thebr-nfe-payment-meansextension to be set automatically to03(cartão de crédito), - tax percentages are provided explicitly as they vary depending on the state and type of goods,
- there are no totals or calculations; all these will be made automatically when uploading, and,
- make sure to process it with the “DF-e issue consumer invoice (NFC-e)” workflow created during setup.
Example B2C consumer invoice for a Simples Nacional issuer (NFC-e)
Example B2C consumer invoice for a Simples Nacional issuer (NFC-e)
- the supplier declares its regime with the
br-nfe-regimeextension set to1(Simples Nacional), - ICMS carries the
br-nfe-icms-csosnextension set to102(taxed without credit permission) with a0%percent, - PIS and COFINS use the
br-nfe-pis-cstandbr-nfe-cofins-cstextensions set to49(other operations) at a0%rate, - the line carries a
br-nfe-cfopextension set to5102, - all of these fields must be set explicitly (i.e., you have them in the minimal example), since the automatic defaults are the normal-regime ones: an ICMS line that omits the CSOSN fails validation, while an omitted PIS or COFINS CST silently falls back to
01, - there are no totals or calculations; all these will be made automatically when uploading, and,
- make sure to process it with the “DF-e issue consumer invoice (NFC-e)” workflow created during setup.
Cancel an invoice
If you need to cancel a document that has already been sent to the tax authority, you can use the cancel workflows created during setup. Run the appropriate cancel workflow — NFS-e, NF-e, or NFC-e — over the silo entry you want to cancel. On success, the entry will be set toVoid.
Configuration
Both cancel actions accept optional parameters that control the cancellation request. They can be set as a default on the workflow step (via the step’s configuration page in the Console) or overridden per job by passing them as arguments when creating the job via the API.FAQ
What type of Documentos Fiscais does Invopop support?
What type of Documentos Fiscais does Invopop support?
Where can I find the mapping of GOBL fields to DF-e documents?
Where can I find the mapping of GOBL fields to DF-e documents?
🇧🇷 Invopop resources for Brazil
🇧🇷 Invopop resources for Brazil