FinOpenPOS
Fiscal Module

Overview

Brazilian fiscal module (NF-e/NFC-e) — standalone @finopenpos/fiscal package

What is @finopenpos/fiscal?

The fiscal module lives in packages/fiscal/ as @finopenpos/fiscal — a standalone package with zero database dependencies. It can be used independently in any TypeScript/JavaScript project.

It implements complete Brazilian electronic invoicing following the SEFAZ MOC 4.00 specification, ported from the PHP sped-nfe library to TypeScript with DDD architecture.

Capabilities

  • NF-e (model 55) — B2B invoices
  • NFC-e (model 65) — consumer invoices
  • Tax engine — ICMS (15 CST + 10 CSOSN), PIS, COFINS, IPI, II, ISSQN
  • XML generation — complete NF-e/NFC-e XML per MOC 4.00
  • Digital signature — XML signing with A1 e-CNPJ (PFX/PKCS#12)
  • SEFAZ communication — authorize, cancel, void, query (mTLS via curl)
  • QR code — NFC-e QR code v2.00/v3.00 (online + offline)
  • Contingency — SVC-AN, SVC-RS, EPEC offline modes
  • IBS/CBS reform events — 14 event types for Brazilian tax reform
  • TXT conversion — legacy SPED format (4 layouts)
  • 754 tests — ported from PHP sped-nfe test suite

Invoice Lifecycle

Loading diagram...

Tax Engine

Loading diagram...

Tax modules never import XML code — they return TaxElement structures that the builder serializes. This keeps domain logic pure and testable.

SEFAZ Communication

Loading diagram...

Why curl? Bun's node:https Agent does not support PFX for mTLS. The workaround extracts PEM from PFX via openssl and uses curl for the HTTPS request.

Detailed Documentation

PageTopic
ArchitectureDDD layers, dependency graph, numeric conventions
Invoice WorkflowService lifecycle, repositories, multi-tenancy
Tax EngineICMS/PIS/COFINS/IPI, TaxElement pattern
XML Generationxml-builder, complement, NF-e XML structure
SEFAZ CommunicationTransport, URLs, request builders, reform events
Certificate & SigningPFX extraction, XML digital signature
Value ObjectsAccessKey (mod-11), TaxId (CPF/CNPJ)
ContingencySVC-AN/SVC-RS, EPEC, offline modes
QR CodeNFC-e QR code v2.00/v3.00
TXT ConversionSPED TXT legacy format conversion
Database SchemaFiscal tables, multi-tenancy
UtilitiesGTIN, CEP lookup, state codes
Emission TestingSEFAZ PR real-world testing notes

On this page