v0.6.0 — Brazilian Fiscal Module (NF-e / NFC-e)
·
34 commits
to main
since this release
Highlights
Complete Brazilian electronic invoicing module — issue, cancel, and void NF-e (model 55) and NFC-e (model 65) with SEFAZ integration, digital signature, and QR code generation.
Fiscal Module (src/lib/fiscal/)
Tax Engine
- ICMS: 15 CST + 10 CSOSN variants with domain field-block helpers (FCP, ST, desoneration)
- PIS/COFINS: generic ContributionTax engine parametrized by tax type (DRY)
- IPI, II, ISSQN support
- TaxElement pattern decouples domain from XML serialization
SEFAZ Integration
- SOAP 1.2 transport with mTLS via curl (Bun PFX workaround)
- State-by-state endpoint registry (all 27 states)
- Request builders, response parsers, event system
- 14 IBS/CBS reform event types (PL_010)
Certificate & Signing
- PFX/PKCS#12 extraction via openssl (with
-legacyflag) - XML digital signature (RSA-SHA1, Exclusive C14N) per MOC 4.00 spec
NFC-e QR Code
- v2.00 (SHA-1) and v3.00 (SHA-256, NT 2025.001)
- Online and offline (contingency) modes
Contingency
- SVC-AN / SVC-RS for NF-e (model 55)
- EPEC for NFC-e (model 65)
- Automatic state→contingency type mapping
Infrastructure
- 4 new database tables: fiscal_settings, invoices, invoice_items, invoice_events
- ~5570 IBGE cities seeded from API
- TXT-to-XML converter for legacy SPED format import
UI
- Invoice list page with status badges and filters
- Invoice detail page with XML viewer
- Fiscal settings page (company, address, certificate, CSC, defaults)
- Product dialog extended with fiscal fields (NCM, CFOP, CST)
- CEP auto-fill via ViaCEP + BrasilAPI
DDD Architecture & Code Quality
- Domain layer: tax modules, value objects (AccessKey, TaxId)
- Infrastructure layer: XML, SEFAZ, certificate, QR code
- DRY refactoring: −300 lines across 19 files
- 12 detailed documentation files in
docs/
Testing
- 840 tests (754 fiscal + 86 tRPC), 0 failures
- Fiscal tests ported from PHP sped-nfe reference suite
- 93.8% coverage on fiscal module
Other Changes
bun run prepare-prodscript for PGLite → PostgreSQL migration (#21)data/directory persistence fix (#19, @Ness55)- Internationalization with next-intl (en + pt-BR)
- READMEs rewritten with TOC, mermaid diagrams, and fiscal documentation
Full Changelog: v0.5.1...v0.6.0