Sign inGet started
Back to blog
Issuing invoices

Tax passthrough

How taxes reach the NF-e: you send the values, Stackin builds the groups, sums the totals, and computes IBS/CBS from the rates.

Brazilian product invoices carry several tax groups on every item — ICMS, IPI, PIS, COFINS and, with the Tax Reform, IBS and CBS — each with its own regime-dependent calculation rules. Stackin is not a tax engine: ICMS, IPI, PIS, and COFINS values arrive already computed by your system in product.br.tax, and Stackin passes them through to the XML in the layout's format, sums the note's totals from them — so the total always matches the items — and checks before sending the rules that can be checked without SEFAZ.

ICMS (state-level tax on the circulation of goods) is the one most sensitive to context: its rate depends on the issuer's state, the buyer's state, and whether the sale is interstate. The rate and amount come in the ICMS group you send; what recipient_address.state decides is whether the note goes out as an internal, interstate, or foreign operation (idDest) and, for a CFOP sent with only its last three digits, what the first digit is.

IPI (federal excise tax on manufactured products) and PIS/COFINS (federal social-contribution taxes) depend on the product's classification and the company's tax regime — Simples Nacional, Lucro Presumido, or Lucro Real each calculate these differently. The regime is registered once on the company and goes on every note; an item sent without tax goes out with no ICMS, PIS, or COFINS due (CSOSN 400 for CRT 1 and 4, Simples Nacional and MEI; CST 41 for the others; on an export, CSOSN 300).

IBS and CBS are where Stackin does the math: you send the CST, the cClassTrib, and the rates in product.br.ibs_cbs, and it computes each item's amounts and the note's total. Before transmitting, it checks in the official cClassTrib table that the classification belongs to the CST, is in force on the issue date, and is allowed on an NF-e, fills the rate reduction of CSTs 011, 200, and 515 from the table when you leave it out, and writes the deferral of CSTs 510 and 515. Choosing the CST, the classification, and the rates is still up to you. See the API reference.

Presumed tax credits, when the company's regime and product qualify for them, are represented as an optional group per item (presumed_credits, up to four, with code, percentage, and amount) rather than a separate calculation step — so a company that needs them isn't blocked, and a company that doesn't never sees the field.

NFS-e works differently: the service tax (ISS) is municipal and goes in the DPS itself, with whether the buyer withholds it, but the rate is configured in the national NFS-e system, which applies it. The NFS-e's IBS and CBS are computed by the Sefin Nacional too — the call carries only the CST, the cClassTrib, and the place-of-supply code. See Issue NFS-e.

None of this makes Stackin a tax advisory service — the classification codes (NCM, CFOP, CEST, the CST, and the cClassTrib) and the tax values still have to be correct for the specific product being sold. What Stackin removes is the work of building the layout's XML, summing the totals, computing IBS and CBS, and catching before SEFAZ the mistakes that can be caught.