Not tax advice. Computation tools only. Have a professional check your work before filing.
openaccountants/skills/brazil-einvoice.md

Use this skill with your AI agent

View on GitHub

Paste this skill into your AI agent's context, or save the file to your project. Works with any AI agent that reads markdown.

brazil-einvoice.md403 lines15.4 KB
v10Brazil
Not yet verified by an accountantContact accountant
1---
2name: brazil-einvoice
3description: >
4 Use this skill whenever asked about Brazil e-invoicing, NF-e (Nota Fiscal Eletrônica), NFS-e (Nota Fiscal de Serviço Eletrônica), NFC-e (Nota Fiscal de Consumidor Eletrônica), CT-e (Conhecimento de Transporte Eletrônico), SEFAZ (Secretaria da Fazenda), DANFE, chave de acesso, XML schema layout 4.00, certificado digital A1/A3, ICMS, IPI, PIS, COFINS, or any question about generating, transmitting, validating, or troubleshooting Brazilian electronic fiscal documents. Also trigger when advising on SEFAZ integration, contingency modes (EPEC, SVC), event handling (cancelamento, carta de correção), or NFS-e national system (SNNFSe). ALWAYS read this skill before touching any Brazil e-invoice work.
5version: 1.0
6jurisdiction: BR
7category: invoicing
8depends_on:
9 - einvoice-workflow-base
10---
11 
12# Brazil E-Invoice (NF-e / NFS-e) Skill v1.0
13 
14---
15 
16## Section 1 -- Quick Reference
17 
18| Field | Value |
19|---|---|
20| Country | Federative Republic of Brazil |
21| Currency | BRL (Real) |
22| E-Invoicing System | Multi-document: NF-e, NFS-e, NFC-e, CT-e, MDF-e |
23| Governing Bodies | Federal: Receita Federal, ENCAT; State: SEFAZ (26 states + DF); Municipal: each municipality |
24| Key Legislation | Federal Constitution Art. 150/155; Lei Complementar 87/96 (ICMS); Ajuste SINIEF 07/2005; NT 2025.002 (tax reform) |
25| Schema Standard | Proprietary XML (W3C compliant); layout version 4.00 |
26| Namespace | http://www.portalfiscal.inf.br/nfe |
27| Implementation Start | 2006 (pilot); mandatory for all since 2014 |
28| Current Status | Fully operational; undergoing tax reform adaptation (IBS/CBS from 2026) |
29| Portal | www.nfe.fazenda.gov.br (NF-e); www.gov.br/nfse (NFS-e Nacional) |
30 
31### Document Type Overview
32 
33| Document | Full Name | Jurisdiction | Use Case |
34|---|---|---|---|
35| NF-e (modelo 55) | Nota Fiscal Eletrônica | State (SEFAZ) | B2B goods sales, interstate transactions |
36| NFC-e (modelo 65) | Nota Fiscal de Consumidor Eletrônica | State (SEFAZ) | B2C point-of-sale retail |
37| NFS-e | Nota Fiscal de Serviço Eletrônica | Municipal → National (SNNFSe) | Services |
38| CT-e | Conhecimento de Transporte Eletrônico | State (SEFAZ) | Freight/transport |
39| MDF-e | Manifesto Eletrônico de Documentos Fiscais | State (SEFAZ) | Transport manifest |
40 
41---
42 
43## Section 2 -- Mandate Scope
44 
45### NF-e (Goods) — Universal Mandate
46 
47- **All taxpayers** engaged in interstate commerce or in ICMS-taxable goods operations
48- No revenue threshold — mandatory for virtually all commercial/industrial establishments
49- Mandatory for: manufacturers, wholesale distributors, importers, exporters
50- Covers: sales, returns, transfers between branches, remittances, complementary/adjustment notes
51 
52### NFC-e (B2C Retail)
53 
54- Replaces the old paper cupom fiscal (ECF)
55- Mandatory for retail establishments (phased in by state; now universal)
56- Simplified format; buyer identification optional for purchases < BRL 200
57 
58### NFS-e (Services)
59 
60- Historically issued per municipal rules (each of Brazil's 5,570 municipalities had own system)
61- National NFS-e system (SNNFSe) launched for unified issuance
62- Transitioning to mandatory use of SNNFSe platform with IBS/CBS fields (2026 reform)
63- Service providers in all municipalities must comply
64 
65### Document Events
66 
67| Event | Code | Description |
68|---|---|---|
69| Cancelamento | 110111 | Cancel within 24 hours (7 days in some states) |
70| Carta de Correção | 110110 | Correction letter for non-financial errors |
71| Confirmação | 210200 | Buyer confirms receipt |
72| Desconhecimento | 210220 | Buyer does not recognize the operation |
73| EPEC | 110140 | Emergency contingency registration |
74 
75---
76 
77## Section 3 -- Technical Format
78 
79### NF-e XML Schema (Layout 4.00)
80 
81| Aspect | Detail |
82|---|---|
83| Format | XML |
84| Layout Version | 4.00 (current since 2019) |
85| Root Element (submission) | `<enviNFe>` |
86| Root Element (single NF-e) | `<NFe>` containing `<infNFe>` |
87| Namespace | http://www.portalfiscal.inf.br/nfe |
88| Digital Signature Namespace | http://www.w3.org/2000/09/xmldsig# |
89| Schema Files | enviNFe_v4.00.xsd, leiauteNFe_v4.00.xsd, etc. |
90| Encoding | UTF-8 |
91| Signature Standard | XMLDSig (enveloped) using ICP-Brasil certificate |
92 
93### Access Key (Chave de Acesso) — 44 Digits
94 
95| Position | Digits | Content |
96|---|---|---|
97| 1-2 | 2 | State code (UF IBGE) |
98| 3-6 | 4 | Year/Month (AAMM) |
99| 7-20 | 14 | CNPJ of issuer |
100| 21-22 | 2 | Model (55=NF-e, 65=NFC-e) |
101| 23-25 | 3 | Series |
102| 26-34 | 9 | NF-e number |
103| 35 | 1 | Emission type (tpEmis) |
104| 36-43 | 8 | Numeric code (random) |
105| 44 | 1 | Check digit (mod 11) |
106 
107### Digital Certificate Requirements
108 
109| Type | Description |
110|---|---|
111| ICP-Brasil A1 | Software-based certificate (file .pfx); valid 1 year |
112| ICP-Brasil A3 | Hardware-based (smart card/token); valid 3 years |
113| Signing | Enveloped XMLDSig; SHA-256 recommended |
114| Certificate in XML | X509Certificate element in `<Signature>` |
115 
116---
117 
118## Section 4 -- Mandatory Fields
119 
120### Identification (ide)
121 
122| Tag | Description | Example |
123|---|---|---|
124| cUF | State code (IBGE) | 35 (São Paulo) |
125| cNF | Random 8-digit code | 12345678 |
126| natOp | Nature of operation | "Venda de mercadoria" |
127| mod | Model | 55 |
128| serie | Series number | 1 |
129| nNF | NF-e number | 000000001 |
130| dhEmi | Emission date/time | 2026-05-22T14:30:00-03:00 |
131| tpNF | Direction (0=input, 1=output) | 1 |
132| idDest | Destination (1=internal, 2=interstate, 3=export) | 2 |
133| cMunFG | Municipality code (IBGE) of taxable event | 3550308 |
134| tpImp | DANFE print format | 1 (portrait) |
135| tpEmis | Emission type | 1 (normal) |
136| tpAmb | Environment (1=production, 2=homologation) | 1 |
137| finNFe | Purpose (1=normal, 2=complementary, 3=adjustment, 4=return) | 1 |
138| indFinal | Final consumer (0=no, 1=yes) | 0 |
139| indPres | Presence indicator | 1 (in-person) |
140 
141### Issuer (emit)
142 
143| Tag | Description |
144|---|---|
145| CNPJ | 14-digit CNPJ |
146| xNome | Legal name |
147| xFant | Trade name |
148| IE | State tax registration (Inscrição Estadual) |
149| CRT | Tax regime (1=Simples Nacional, 2=SN excess, 3=Normal) |
150| enderEmit | Full address (xLgr, nro, xBairro, cMun, UF, CEP) |
151 
152### Recipient (dest)
153 
154| Tag | Description |
155|---|---|
156| CNPJ or CPF | Recipient tax ID |
157| xNome | Name |
158| indIEDest | IE indicator (1=ICMS contributor, 2=exempt, 9=non-contributor) |
159| IE | State registration (if contributor) |
160| enderDest | Full address |
161 
162### Products (det/prod)
163 
164| Tag | Description |
165|---|---|
166| cProd | Internal product code |
167| cEAN | GTIN barcode (or "SEM GTIN") |
168| xProd | Product description |
169| NCM | Mercosur nomenclature code (8 digits) |
170| CFOP | Fiscal operation code (4 digits) |
171| uCom | Unit of measure |
172| qCom | Quantity |
173| vUnCom | Unit price |
174| vProd | Total product value (qCom × vUnCom) |
175| cEANTrib | Tax unit barcode |
176| uTrib | Tax unit of measure |
177| qTrib | Tax quantity |
178| vUnTrib | Tax unit price |
179 
180### Taxes (det/imposto)
181 
182| Tax Group | Tags | Description |
183|---|---|---|
184| ICMS | orig, CST/CSOSN, modBC, vBC, pICMS, vICMS | State goods circulation tax |
185| IPI | CST, vBC, pIPI, vIPI | Federal excise (manufactured goods) |
186| PIS | CST, vBC, pPIS, vPIS | Federal social contribution |
187| COFINS | CST, vBC, pCOFINS, vCOFINS | Federal social contribution |
188 
189### Totals (total/ICMSTot)
190 
191| Tag | Description |
192|---|---|
193| vBC | Total ICMS tax base |
194| vICMS | Total ICMS |
195| vProd | Total products |
196| vFrete | Total freight |
197| vSeg | Total insurance |
198| vDesc | Total discounts |
199| vIPI | Total IPI |
200| vPIS | Total PIS |
201| vCOFINS | Total COFINS |
202| vNF | Total NF-e value |
203 
204---
205 
206## Section 5 -- Transmission Method
207 
208### SEFAZ Web Services
209 
210| Service | WSDL Action | Purpose |
211|---|---|---|
212| NfeAutorizacao | NfeAutorizacaoLote | Submit batch of NF-e for authorization |
213| NfeRetAutorizacao | NfeRetAutorizacaoLote | Query authorization result |
214| NfeConsultaProtocolo | NfeConsulta | Query single NF-e status |
215| NfeInutilizacao | NfeInutilizacao | Number range cancellation |
216| RecepcaoEvento | NfeRecepcaoEvento | Submit events (cancel, correction, etc.) |
217| NfeStatusServico | NfeStatusServico | Check SEFAZ availability |
218| NfeDistribuicaoDFe | NFeDistribuicaoDFe | Download DFe addressed to taxpayer |
219 
220### SEFAZ Environments
221 
222| Environment | URL Pattern | Purpose |
223|---|---|---|
224| Production | https://nfe.sefaz{UF}.{domain}/... | Live transactions |
225| Homologation | https://homologacao.nfe.sefaz{UF}.{domain}/... | Testing |
226 
227### Virtual SEFAZ (SVRS / SVC)
228 
229- States that don't host their own SEFAZ use SVRS (Sefaz Virtual RS) or SVAN (Sefaz Virtual AN)
230- Contingency modes: SVC-AN, SVC-RS (when primary SEFAZ is down)
231- EPEC: Evento Prévio de Emissão em Contingência (offline pre-registration)
232 
233### Authorization Flow
234 
2351. Generate NF-e XML (all mandatory fields)
2362. Sign XML with ICP-Brasil certificate (XMLDSig enveloped)
2373. Submit to SEFAZ via NfeAutorizacao web service (synchronous or batch)
2384. SEFAZ validates schema, business rules, digital signature
2395. SEFAZ returns protocolo de autorização (authorization protocol) with status code
2406. Embed authorization protocol in NF-e XML (nfeProc) → legally valid document
2417. Generate DANFE (auxiliary printed document) for transport accompaniment
2428. Deliver XML to recipient within 24 hours
243 
244---
245 
246## Section 6 -- Validation Rules
247 
248### SEFAZ Validation Layers
249 
2501. **Schema validation** — XML conforms to leiauteNFe_v4.00.xsd
2512. **Digital signature** — Valid ICP-Brasil certificate; signature mathematically correct
2523. **Business rules** — ~900+ validation rules defined in Notas Técnicas
2534. **Tax calculation** — ICMS, IPI, PIS, COFINS amounts verified against rates and bases
2545. **Cross-reference** — CNPJ/IE must be active in SEFAZ cadastro
2556. **GTIN validation** — Barcode must exist in CCG (Cadastro Centralizado de GTINs)
2567. **Duplicate check** — Same chave de acesso cannot be authorized twice
257 
258### Common Rejection Codes
259 
260| Code | Description | Fix |
261|---|---|---|
262| 204 | Duplicate NF-e (same access key) | Use new nNF or cNF |
263| 215 | Schema validation error | Fix XML structure per XSD |
264| 225 | Invalid destination state for CFOP | Align CFOP with idDest |
265| 301 | Irregular use of IE | Verify IE is active in destination state |
266| 539 | Duplicate NF-e (duplicate content) | Review NF-e number sequence |
267| 611 | GTIN not found in CCG | Register product GTIN or use "SEM GTIN" |
268| 778 | NCM incompatible with CFOP | Check NCM-CFOP alignment |
269 
270### Authorization Status Codes
271 
272| Code | Meaning |
273|---|---|
274| 100 | Authorized |
275| 101 | Cancellation authorized |
276| 110 | Use denied (registered but not authorized) |
277| 135 | Event registered |
278| 301-999 | Various rejection codes |
279 
280---
281 
282## Section 7 -- Tax Computation Rules
283 
284### ICMS (State Tax)
285 
286- Rates vary by state and product (7%, 12%, 17%, 18%, 19%, 20%, 25% most common)
287- Interstate rates: 4% (imported goods), 7% (South/Southeast → other), 12% (other combinations)
288- ICMS-ST (substituição tributária): tax collected in advance by manufacturer/importer
289- DIFAL: differential rate for interstate B2C to final consumer
290 
291### IPI (Federal Excise)
292 
293- Applied on manufactured/imported goods
294- Rates from 0% to 365% depending on product (TIPI table)
295- Simples Nacional companies generally exempt from IPI credit
296 
297### PIS/COFINS (Federal Social Contributions)
298 
299| Regime | PIS Rate | COFINS Rate | Method |
300|---|---|---|---|
301| Cumulativo (presumed profit) | 0.65% | 3.00% | On gross revenue, no credits |
302| Não-cumulativo (real profit) | 1.65% | 7.60% | On revenue minus credits |
303 
304### Tax Reform (IBS/CBS) — From 2026
305 
306- NT 2025.002 introduces new XML groups for IBS (state/municipal) and CBS (federal)
307- Transitional period: IBS/CBS coexist with ICMS/ISS/PIS/COFINS until full replacement (2033)
308- New fields in NF-e XML for IBS and CBS amounts
309 
310### Rounding Rules
311 
312- Monetary values: 2 decimal places
313- Quantities: up to 4 decimal places
314- Unit prices: up to 10 decimal places
315- Tax rates: up to 4 decimal places
316- Tolerance in tax totals: BRL 0.01 per tax group
317 
318---
319 
320## Section 8 -- Archiving Requirements
321 
322| Requirement | Detail |
323|---|---|
324| Retention Period | Minimum 5 years from first day of following fiscal year (decadência tributária) |
325| Format | Original authorized XML (with protocolo de autorização embedded) |
326| Recipient Obligation | Must store received NF-e XML for same period |
327| DANFE | Not a substitute for XML; printed for transport only |
328| Events | All events (cancellation, correction letters) must be archived alongside |
329| Digital Signature | Preserved within the XML; no separate signature file |
330| Access | Must be producible on demand during fiscal audit (SEFAZ or Receita Federal) |
331| Backup | Recommended redundant storage; SEFAZ maintains copy but taxpayer remains responsible |
332 
333---
334 
335## Section 9 -- Penalties for Non-Compliance
336 
337| Violation | Penalty |
338|---|---|
339| Operating without NF-e when required | 1% of transaction value (minimum BRL 500) per document; varies by state |
340| Issuing NF-e with incorrect data | Fine varies by state (typically 1% of NF-e value) |
341| Not transmitting NF-e to SEFAZ | Goods seizure during transport + fine |
342| Transporting goods without DANFE | Goods seizure + fine (state regulation) |
343| Not delivering XML to recipient | Administrative fine + recipient cannot claim credits |
344| Late cancellation | Fine; cancellation may be denied after deadline |
345| Operating with revoked/expired certificate | NF-e rejection; inability to operate |
346 
347### State-Specific Penalty Ranges (Examples)
348 
349| State | Typical Fine for Missing NF-e |
350|---|---|
351| São Paulo (SP) | 50% of transaction value (ICMS-related) |
352| Minas Gerais (MG) | 40% of transaction value |
353| Rio de Janeiro (RJ) | Minimum 5 UFIR-RJ per document |
354| Paraná (PR) | 30% of transaction value |
355 
356Penalties compound if multiple violations occur in the same audit period.
357 
358---
359 
360## Section 10 -- Interaction with Tax Skills
361 
362### SPED Fiscal (EFD ICMS/IPI)
363 
364- Monthly digital bookkeeping obligation that references all NF-e issued/received
365- Bloco C (goods) populated from NF-e XML data
366- Cross-validation: SPED entries must match SEFAZ-authorized NF-e records exactly
367- Discrepancies trigger automatic SEFAZ audit notices
368 
369### EFD-Contribuições (PIS/COFINS)
370 
371- Federal digital bookkeeping for PIS/COFINS
372- Line-item detail from NF-e feeds into credit/debit calculations
373- CST codes in NF-e determine PIS/COFINS treatment in EFD
374 
375### SPED ECD / ECF (Accounting / Corporate Tax)
376 
377- Revenue recognized in corporate books must align with NF-e issuance
378- Receita Federal cross-references ECF declarations against NF-e aggregate data
379 
380### NFS-e → ISS Return
381 
382- NFS-e data feeds municipal ISS (Imposto Sobre Serviços) return
383- With SNNFSe national system, ISS data will flow to national IBS calculations (reform)
384 
385### DCTF / DARF
386 
387- Federal tax payments (IPI, PIS, COFINS) reconciled against NF-e-derived obligations
388- Under tax reform: CBS replaces PIS/COFINS with data sourced from NF-e/NFS-e
389 
390### Import/Export (DI/DUE)
391 
392- Export NF-e linked to DU-E (Declaração Única de Exportação)
393- Import NF-e references DI (Declaração de Importação) number
394- CFOP codes 3.xxx (imports) and 7.xxx (exports) tie to customs documentation
395 
396---
397 
398## Disclaimer
399 
400This skill and its outputs are provided for informational and computational purposes only and do not constitute tax, legal, or financial advice. Open Accountants and its contributors accept no liability for any errors, omissions, or outcomes arising from the use of this skill. All outputs must be reviewed and signed off by a qualified professional (such as a Contador, CRC-registered accountant, or equivalent licensed practitioner in your jurisdiction) before filing or acting upon.
401 
402The most up-to-date, verified version of this skill is maintained at [openaccountants.com](https://openaccountants.com).
403 

Run this skill, then get an accountant to check it

After running the full skill pack in your AI agent, sign up and upload your worksheet. We'll connect you with a trusted accountant in our network who can review your numbers before you file.

Verification status

Research-verified

Drafted from authoritative sources (tax authority sites, Big-4 summaries). Awaiting credentialed sign-off.

Needs section-by-section practitioner review to reach accountant-verified.

Section review progress

0/39

About

Use this skill whenever asked about Brazil e-invoicing, NF-e (Nota Fiscal Eletrônica), NFS-e (Nota Fiscal de Serviço Eletrônica), NFC-e (Nota Fiscal de Consumidor Eletrônica), CT-e (Conhecimento de Transporte Eletrônico), SEFAZ (Secretaria da Fazenda), DANFE, chave de acesso, XML schema layout 4.00, certificado digital A1/A3, ICMS, IPI, PIS, COFINS, or any question about generating, transmitting, validating, or troubleshooting Brazilian electronic fiscal documents. Also trigger when advising on SEFAZ integration, contingency modes (EPEC, SVC), event handling (cancelamento, carta de correção), or NFS-e national system (SNNFSe). ALWAYS read this skill before touching any Brazil e-invoice work.

BRty-2025

Use this skill

This skill is open source and free to use in any AI agent. Copy it, download it, or clone the repo. If you find an error, report an issue — a licensed accountant will review.

8 of 12 in the BR workflow: