Skip to main content
Key: br-nfe-v4 Module: github.com/invopop/gobl.br.nfe

Correction Definitions

Auto-generation of corrective invoices or credit and debit notes is supported.

Invoice Types

The types of invoices that can be created with a preceding definition:
  • credit-note
  • debit-note

Stamp Keys

Stamp keys from the previous invoice that need to be referenced:
  • sefaz-key

Scenarios

bill/invoice

Filters:
  • Types: standard, credit-note, debit-note
Output:
  • Extensions: br-nfe-model:55
Filters:
  • Types: standard, credit-note, debit-note
  • Tags: simplified
Output:
  • Extensions: br-nfe-model:65
Filters:
  • Types: standard
Output:
  • Extensions: br-nfe-operation-type:1, br-nfe-purpose:1

Extensions

Fiscal Document Model Code

Code used to identify the fiscal document model. It will be determined automatically by GOBL during normalization according to the scenario definitions.
CodeName
55NF-e
65NFC-e

Buyer Presence Indicator

Indicator of the buyer’s presence at the commercial establishment at the time of the operation. This field is used to classify the type of commercial transaction according to Brazilian tax regulations.
CodeName
0Not applicable
1In-person operation
2Non-in-person operation, via Internet
3Non-in-person operation, Tele-service
4NFC-e in operation with home delivery
5In-person operation, outside establishment
9Non-in-person operation, others

Payment Method

Code used to identify the payment method used for the transaction.
CodeName
01Cash
02Check
03Credit Card
04Debit Card
05Store Credit
10Food Voucher
11Meal Voucher
12Gift Voucher
13Fuel Voucher
15Bank Slip (Boleto)
16Bank Deposit
17Instant Payment (PIX)
18Bank Transfer, Digital Wallet
19Loyalty Program, Cashback, Virtual Credit
90No Payment
99Others

CFOP (Fiscal Operations and Services Code)

Four-digit code that classifies the nature of goods movements and service provisions for ICMS purposes in Brazil. The first digit indicates the operation origin/destination (1–3 for entries; 5–7 for exits), and the remaining digits identify the specific type of operation.
Pattern: ^[1-7]\d{3}$

Fiscal Incentive Indicator

Indicates whether a party benefits from a fiscal incentive.
CodeName
1Has incentive
2Does not have incentive

Tax Regime Code

Indicates the tax regime that a party is subject to. Defaults to 3 (normal regime) during normalization when not provided.
CodeName
1Simples Nacional
2Simples Nacional, Excess
3Normal
4MEI - Individual Micro-entrepreneur

Special Tax Regime Code

Indicates a special tax regime that a party is subject to.
CodeName
1Municipal micro-enterprise
2Estimated
3Professional Society
4Cooperative
5Single micro-entrepreneur (MEI)
6Micro-enterprise or Small Business (ME EPP)

ICMS Tax Status Code (CST)

ICMS tax status code (CST) for the line item, used by issuers under the normal regime (br-nfe-regime 3). Simples Nacional issuers must use the CSOSN code (br-nfe-icms-csosn) instead. Defaults to 00 (taxed in full) during normalization when not provided.
CodeName
00Taxed in full
02Monophasic taxation (fuels)
10Taxed with ICMS charged by tax substitution
15Fuel operation with ICMS retention
20Taxed with tax base reduction
30Exempt/non-taxed with ICMS charged by tax substitution
40Exempt
41Non-taxed
50Suspended
51Deferred
53Fuel operation with deferral
60ICMS charged previously by tax substitution
61Fuel operation with ICMS withheld
70Taxed with base reduction and ICMS charged by tax substitution
90Others

ICMS Simples Nacional Status Code (CSOSN)

ICMS status code (CSOSN) for the line item, used by issuers under the Simples Nacional regime (br-nfe-regime 1, 2 or 4). Normal-regime issuers must use the CST code (br-nfe-icms-cst) instead.
CodeName
101Taxed under Simples Nacional with credit permission
102Taxed under Simples Nacional without credit permission
103ICMS exemption under Simples Nacional for gross revenue range
201Taxed under Simples Nacional with credit permission and ICMS by tax substitution
202Taxed under Simples Nacional without credit permission and ICMS by tax substitution
203ICMS exemption under Simples Nacional for revenue range and ICMS by tax substitution
300Immune
400Non-taxed under Simples Nacional
500ICMS charged previously by tax substitution or anticipation
900Others

ICMS Goods Origin

Origin of the goods for ICMS purposes. Defaults to 0 (national) during normalization when not provided.
CodeName
0National (except codes 3, 4, 5 and 8)
1Foreign, direct import (except code 6)
2Foreign, acquired in the domestic market (except code 7)
3National, import content above 40% and up to 70%
4National, produced under the basic productive processes
5National, import content up to 40%
6Foreign, direct import, no domestic equivalent (CAMEX list / natural gas)
7Foreign, acquired domestically, no domestic equivalent (CAMEX list / natural gas)
8National, import content above 70%

PIS Tax Status Code (CST)

PIS tax status code for the line item. Simples Nacional issuers typically use 49 or 99, as PIS is settled within the unified DAS collection. Defaults to 01 (standard-rate taxable operation) during normalization when not provided.
CodeName
01Taxable operation, standard rate
02Taxable operation, differentiated rate
03Taxable operation, rate per unit of measure
04Taxable monophasic operation, zero-rate resale
05Taxable operation by tax substitution
06Taxable operation, zero rate
07Operation exempt from the contribution
08Operation without incidence of the contribution
09Operation with suspension of the contribution
49Other outbound operations
50Credit operation, exclusively taxed domestic revenue
51Credit operation, exclusively non-taxed domestic revenue
52Credit operation, exclusively export revenue
53Credit operation, taxed and non-taxed domestic revenue
54Credit operation, taxed domestic and export revenue
55Credit operation, non-taxed domestic and export revenue
56Credit operation, taxed/non-taxed domestic and export revenue
60Presumed credit, exclusively taxed domestic revenue
61Presumed credit, exclusively non-taxed domestic revenue
62Presumed credit, exclusively export revenue
63Presumed credit, taxed and non-taxed domestic revenue
64Presumed credit, taxed domestic and export revenue
65Presumed credit, non-taxed domestic and export revenue
66Presumed credit, taxed/non-taxed domestic and export revenue
67Presumed credit, other operations
70Acquisition operation without credit right
71Acquisition operation with exemption
72Acquisition operation with suspension
73Acquisition operation at zero rate
74Acquisition operation without incidence of the contribution
75Acquisition operation by tax substitution
98Other inbound operations
99Other operations

COFINS Tax Status Code (CST)

COFINS tax status code for the line item. Simples Nacional issuers typically use 49 or 99, as COFINS is settled within the unified DAS collection. Defaults to 01 (standard-rate taxable operation) during normalization when not provided.
CodeName
01Taxable operation, standard rate
02Taxable operation, differentiated rate
03Taxable operation, rate per unit of measure
04Taxable monophasic operation, zero-rate resale
05Taxable operation by tax substitution
06Taxable operation, zero rate
07Operation exempt from the contribution
08Operation without incidence of the contribution
09Operation with suspension of the contribution
49Other outbound operations
50Credit operation, exclusively taxed domestic revenue
51Credit operation, exclusively non-taxed domestic revenue
52Credit operation, exclusively export revenue
53Credit operation, taxed and non-taxed domestic revenue
54Credit operation, taxed domestic and export revenue
55Credit operation, non-taxed domestic and export revenue
56Credit operation, taxed/non-taxed domestic and export revenue
60Presumed credit, exclusively taxed domestic revenue
61Presumed credit, exclusively non-taxed domestic revenue
62Presumed credit, exclusively export revenue
63Presumed credit, taxed and non-taxed domestic revenue
64Presumed credit, taxed domestic and export revenue
65Presumed credit, non-taxed domestic and export revenue
66Presumed credit, taxed/non-taxed domestic and export revenue
67Presumed credit, other operations
70Acquisition operation without credit right
71Acquisition operation with exemption
72Acquisition operation with suspension
73Acquisition operation at zero rate
74Acquisition operation without incidence of the contribution
75Acquisition operation by tax substitution
98Other inbound operations
99Other operations

Purpose Code

Code that identifies the purpose of the fiscal document (SEFAZ field finNFe, B25). Standard invoices are set to 1 (normal) via a tax scenario.
CodeName
1Normal
2Complementary
3Adjustment
4Goods Return
5Credit Note
6Debit Note

Operation Type Code

Code that identifies the type of operation, indicating whether it is inbound or outbound (SEFAZ field tpNF, B11). Standard invoices are set to 1 (outbound) via a tax scenario.
CodeName
0Inbound
1Outbound

Credit Note Type Code

Code that identifies the type of credit note (SEFAZ field tpNFCredito, B25.2) according to the RTM (applies to IBS/CBS only).
CodeName
01Penalty and interest
02Appropriation of presumed IBS credit in the ZFM
03Return
04Reduction of values
05Credit transfer on succession

Debit Note Type Code

Code that identifies the type of debit note (SEFAZ field tpNFDebito, B25.1) according to the RTM (applies to IBS/CBS only).
CodeName
01Transfer of credits from Cooperatives
02Credit annulment
03Debits not processed in the regular assessment
04Penalty and interest
05Credit transfer on succession
06Advance payment
07Inventory loss
08Exit from Simples Nacional

Validation Rules

FieldTestValidation Code / Message
Invoice
  • Can convert to [BRL]
GOBL-BR-NFE-BILL-INVOICE-34
Invoice currency must be BRL or provide exchange rate for conversion
Invoice
  • Has reason note
GOBL-BR-NFE-BILL-INVOICE-30
Invoice requires a note with key ‘reason’ to describe the nature of the operation (natOp)
supplier.tax_id
  • Present
GOBL-BR-NFE-BILL-INVOICE-01
Invoice supplier tax ID is required
supplier.tax_id.code
  • Present
GOBL-BR-NFE-BILL-INVOICE-02
Invoice supplier tax ID code is required
supplier.addresses[*]
  • Present
GOBL-BR-NFE-BILL-INVOICE-03
Invoice supplier address must not be empty
supplier.addresses[*].street
  • Present
GOBL-BR-NFE-BILL-INVOICE-04
Invoice supplier address requires a street
supplier.addresses[*].num
  • Present
GOBL-BR-NFE-BILL-INVOICE-05
Invoice supplier address requires a number
supplier.addresses[*].locality
  • Present
GOBL-BR-NFE-BILL-INVOICE-06
Invoice supplier address requires a locality
supplier.addresses[*].state
  • Present
GOBL-BR-NFE-BILL-INVOICE-07
Invoice supplier address requires a state
supplier.addresses[*].code
  • Present
GOBL-BR-NFE-BILL-INVOICE-08
Invoice supplier address requires a postal code
supplier.addresses[*].country
  • Present
GOBL-BR-NFE-BILL-INVOICE-37
Invoice supplier address requires a country
supplier.ext
  • Has addresses
  • Ext require [br-ibge-municipality]
GOBL-BR-NFE-BILL-INVOICE-09
Invoice supplier requires ‘br-ibge-municipality’ extension when addresses are present
supplier.ext
  • Ext require [br-nfe-regime]
GOBL-BR-NFE-BILL-INVOICE-39
Invoice supplier requires ‘br-nfe-regime’ extension
supplier.name
  • Present
GOBL-BR-NFE-BILL-INVOICE-10
Invoice supplier name is required
supplier.addresses
  • Present
GOBL-BR-NFE-BILL-INVOICE-11
Invoice supplier must have at least one address
customer
  • Invoice is NFe
  • Present
GOBL-BR-NFE-BILL-INVOICE-12
Invoice customer is required for NF-e invoices
customer.addresses
  • Invoice is NFe
  • Present
GOBL-BR-NFE-BILL-INVOICE-13
Invoice customer must have at least one address for NF-e invoices
customer
  • No tax ID
  • Has foreign country identity
GOBL-BR-NFE-BILL-INVOICE-36
Invoice customer must have a tax ID or a foreign country identity
customer.tax_id.code
  • Present
GOBL-BR-NFE-BILL-INVOICE-15
Invoice customer tax ID code is required
customer.addresses[*]
  • Present
GOBL-BR-NFE-BILL-INVOICE-16
Invoice customer address must not be empty
customer.addresses[*].street
  • Present
GOBL-BR-NFE-BILL-INVOICE-17
Invoice customer address requires a street
customer.addresses[*].num
  • Present
GOBL-BR-NFE-BILL-INVOICE-18
Invoice customer address requires a number
customer.addresses[*].locality
  • Present
GOBL-BR-NFE-BILL-INVOICE-19
Invoice customer address requires a locality
customer.addresses[*].code
  • Present
GOBL-BR-NFE-BILL-INVOICE-21
Invoice customer address requires a postal code
customer.addresses[*].country
  • Present
GOBL-BR-NFE-BILL-INVOICE-38
Invoice customer address requires a country
customer.addresses[*].state
  • Is Brazilian
  • Present
GOBL-BR-NFE-BILL-INVOICE-20
Invoice customer address requires a state
customer.ext
  • Has addresses
  • Ext require [br-ibge-municipality]
GOBL-BR-NFE-BILL-INVOICE-22
Invoice customer requires ‘br-ibge-municipality’ extension when addresses are present
series
  • Present
GOBL-BR-NFE-BILL-INVOICE-23
Invoice series is required
series
  • Matches ^(?:0|[1-9][0-9])$
GOBL-BR-NFE-BILL-INVOICE-24
Invoice series format is invalid; must be 0 or 1-999
tax
  • Present
GOBL-BR-NFE-BILL-INVOICE-25
Invoice tax is required
tax.ext
  • Ext require [br-nfe-model, br-nfe-presence, br-nfe-purpose, br-nfe-operation-type]
GOBL-BR-NFE-BILL-INVOICE-26
Invoice tax requires ‘br-nfe-model’, ‘br-nfe-presence’, ‘br-nfe-purpose’ and ‘br-nfe-operation-type’ extensions
tax.ext
  • NFe model
  • Ext ‘br-nfe-presence’ not in [4]
GOBL-BR-NFE-BILL-INVOICE-27
NF-e invoices do not support ‘4’ for ‘br-nfe-presence’
tax.ext
  • NFCe model
  • Ext ‘br-nfe-presence’ in [1, 4]
GOBL-BR-NFE-BILL-INVOICE-28
NFC-e invoices require in-person or delivery for ‘br-nfe-presence’
tax.ext
  • Credit note purpose
  • Ext require [br-nfe-credit-note-type]
GOBL-BR-NFE-BILL-INVOICE-40
Credit note invoices require ‘br-nfe-credit-note-type’ extension
tax.ext
  • Debit note purpose
  • Ext require [br-nfe-debit-note-type]
GOBL-BR-NFE-BILL-INVOICE-41
Debit note invoices require ‘br-nfe-debit-note-type’ extension
notes[*].text
  • Reason note
  • Length between 1 and 60
GOBL-BR-NFE-BILL-INVOICE-29
Invoice reason note text must be between 1 and 60 characters
payment
  • Invoice not paid
  • Present
GOBL-BR-NFE-BILL-INVOICE-31
Invoice payment is required when invoice is unpaid
payment.instructions
  • Invoice not paid
  • Present
GOBL-BR-NFE-BILL-INVOICE-32
Invoice payment instructions are required when invoice is unpaid
totals.due
Calculated
  • Zero or positive
GOBL-BR-NFE-BILL-INVOICE-33
Invoice due amount must not be negative
lines[*].ext
  • Invoice is NFe
  • Ext require [br-nfe-cfop]
GOBL-BR-NFE-BILL-INVOICE-35
NF-e invoice lines require ‘br-nfe-cfop’ extension
FieldTestValidation Code / Message
Line
  • Line has tax category ICMS
GOBL-BR-NFE-BILL-LINE-01
Line taxes must include the ICMS category
Line
  • Line has tax category PIS
GOBL-BR-NFE-BILL-LINE-02
Line taxes must include the PIS category
Line
  • Line has tax category COFINS
GOBL-BR-NFE-BILL-LINE-03
Line taxes must include the COFINS category
FieldTestValidation Code / Message
ext
  • ICMS category
  • Ext require [br-nfe-icms-cst], or ext require [br-nfe-icms-csosn]
GOBL-BR-NFE-TAX-COMBO-01
ICMS tax combo requires ‘br-nfe-icms-cst’ or ‘br-nfe-icms-csosn’ extension
ext
  • ICMS category
  • Ext require [br-nfe-icms-origin]
GOBL-BR-NFE-TAX-COMBO-02
ICMS tax combo requires ‘br-nfe-icms-origin’ extension
ext
  • PIS category
  • Ext require [br-nfe-pis-cst]
GOBL-BR-NFE-TAX-COMBO-03
PIS tax combo requires ‘br-nfe-pis-cst’ extension
ext
  • COFINS category
  • Ext require [br-nfe-cofins-cst]
GOBL-BR-NFE-TAX-COMBO-04
COFINS tax combo requires ‘br-nfe-cofins-cst’ extension
FieldTestValidation Code / Message
ext
  • Ext require [br-nfe-payment-means]
GOBL-BR-NFE-PAY-INSTRUCTIONS-01
Payment instructions require ‘br-nfe-payment-means’ extension
FieldTestValidation Code / Message
ext
  • Ext require [br-nfe-payment-means]
GOBL-BR-NFE-PAY-RECORD-01
Payment advance requires ‘br-nfe-payment-means’ extension