Expand description
Core types, tax computation, and XML generation for Brazilian fiscal documents.
fiscal-core is the foundation crate of the fiscal-rs workspace. It contains:
- Data types (
types,newtypes) — strongly-typed structs and newtypes for NF-e / NFC-e document data, validated at construction time. - Tax computation (
tax_icms,tax_pis_cofins_ipi,tax_issqn,tax_is) — build XML fragments for each Brazilian tax group and accumulate invoice totals. - XML builder (
xml_builder) — typestate builder for assembling a complete, schema-compliant NF-e / NFC-e XML document. - Protocol helpers (
complement,contingency,qrcode) — attach SEFAZ authorization protocols, manage contingency mode, and build NFC-e QR codes. - Utilities (
format_utils,xml_utils,gtin,state_codes,status_codes,constants) — formatting, XML escaping, GTIN validation, IBGE state code lookups, and SEFAZ status-code constants. - Conversion (
convert,standardize) — TXT-to-XML converter and XML type identification / JSON conversion. - Traits (
traits) — sealedTaxCalculationandXmlSerializabletraits.
Re-exports§
pub use error::FiscalError;
Modules§
- complement
- Functions for attaching SEFAZ authorization protocols to signed XML documents.
- config
- Configuration validation for Brazilian fiscal documents.
- constants
- Compile-time constants: namespaces, algorithm URIs, and payment type codes. Compile-time constants used throughout NF-e XML generation.
- contingency
- Contingency mode manager for NF-e fallback emission.
- convert
- SPED TXT-to-XML converter for NF-e documents. TXT-to-XML converter for NF-e/NFC-e.
- error
- Error types for all fiscal operations.
- format_
utils - Formatting helpers for monetary amounts, rates, and decimal numbers. Formatting helpers for monetary amounts, rates, and decimal numbers.
- gtin
- GTIN (barcode) validation and check-digit calculation.
- newtypes
- Parse-don’t-validate newtypes for monetary amounts, tax rates, access keys, and state codes. Parse-don’t-validate newtypes for monetary amounts, tax rates, access keys, and state codes.
- qrcode
- NFC-e QR code URL builder and XML injection.
- sanitize
- ASCII sanitization for XML text content (replaces accented characters). ASCII sanitization for XML text content.
- sealed
- Sealed trait infrastructure for preventing external implementations. Sealed trait infrastructure.
- standardize
- NF-e XML document type identification and XML-to-JSON conversion.
- state_
codes - Brazilian state IBGE code lookup tables and helpers. Brazilian state IBGE code lookup tables and helper functions.
- status_
codes - SEFAZ status code constants and valid-status sets.
SEFAZ status code constants (
cStat) and valid-status sets. - tax_
element - Internal tax element types used by tax computation modules. Internal building blocks for tax XML element serialisation.
- tax_
ibs_ cbs - IBS/CBS (Imposto sobre Bens e Servicos / Contribuicao sobre Bens e Servicos) XML generation. IBS/CBS (Imposto sobre Bens e Servicos / Contribuicao sobre Bens e Servicos) XML generation for NF-e items – PL_010 tax reform.
- tax_
icms - ICMS tax computation and XML generation (CST and CSOSN variants). ICMS tax computation and XML generation for NF-e / NFC-e documents.
- tax_is
- IS (Imposto Seletivo) XML generation. IS (Imposto Seletivo) XML generation for NF-e items — PL_010 tax reform.
- tax_
issqn - ISSQN (municipal service tax) XML generation. ISSQN (ISS — Imposto Sobre Serviços) XML generation for NF-e service items.
- tax_
pis_ cofins_ ipi - PIS, COFINS, IPI, and II tax computation and XML generation. PIS, COFINS, IPI, and II (import tax) XML generation for NF-e items.
- timezone
- Timezone lookup by Brazilian state (UF). Timezone lookup by Brazilian state (UF).
- traits
- Sealed public traits:
TaxCalculationandXmlSerializable. Sealed public traits for tax calculation and XML serialization. - types
- Public data structures for NF-e / NFC-e documents. Public data structures for NF-e / NFC-e documents.
- xml_
builder - Typestate XML builder for NF-e / NFC-e documents. NF-e/NFC-e XML builder module.
- xml_
utils - XML building primitives:
tag,escape_xml, andextract_xml_tag_value. Low-level XML building primitives used throughout the crate.