Skip to main content

Crate fiscal_core

Crate fiscal_core 

Source
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) — sealed TaxCalculation and XmlSerializable traits.

Re-exports§

pub use error::FiscalError;

Modules§

complement
Functions for attaching SEFAZ authorization protocols to signed XML 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 and validator for NFe documents.
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.
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.
traits
Sealed public traits: TaxCalculation and XmlSerializable. 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, and extract_xml_tag_value. Low-level XML building primitives used throughout the crate.