fiscal_core/lib.rs
1//! Core types, tax computation, and XML generation for Brazilian fiscal documents.
2//!
3//! `fiscal-core` is the foundation crate of the `fiscal-rs` workspace. It contains:
4//!
5//! - **Data types** ([`types`], [`newtypes`]) — strongly-typed structs and newtypes for
6//! NF-e / NFC-e document data, validated at construction time.
7//! - **Tax computation** ([`tax_icms`], [`tax_pis_cofins_ipi`], [`tax_issqn`], [`tax_is`]) —
8//! build XML fragments for each Brazilian tax group and accumulate invoice totals.
9//! - **XML builder** ([`xml_builder`]) — typestate builder for assembling a complete,
10//! schema-compliant NF-e / NFC-e XML document.
11//! - **Protocol helpers** ([`complement`], [`contingency`], [`qrcode`]) — attach SEFAZ
12//! authorization protocols, manage contingency mode, and build NFC-e QR codes.
13//! - **Utilities** ([`format_utils`], [`xml_utils`], [`gtin`], [`state_codes`],
14//! [`status_codes`], [`constants`]) — formatting, XML escaping, GTIN validation,
15//! IBGE state code lookups, and SEFAZ status-code constants.
16//! - **Conversion** ([`convert`], [`standardize`]) — TXT-to-XML converter and
17//! XML type identification / JSON conversion.
18//! - **Traits** ([`traits`]) — sealed `TaxCalculation` and `XmlSerializable` traits.
19
20pub mod error;
21pub use error::FiscalError;
22
23/// Functions for attaching SEFAZ authorization protocols to signed XML documents.
24pub mod complement;
25/// Compile-time constants: namespaces, algorithm URIs, and payment type codes.
26pub mod constants;
27/// Contingency mode manager for NF-e fallback emission.
28pub mod contingency;
29/// SPED TXT-to-XML converter for NF-e documents.
30pub mod convert;
31/// Formatting helpers for monetary amounts, rates, and decimal numbers.
32pub mod format_utils;
33/// GTIN (barcode) validation and check-digit calculation.
34pub mod gtin;
35/// Parse-don't-validate newtypes for monetary amounts, tax rates, access keys, and state codes.
36pub mod newtypes;
37/// NFC-e QR code URL builder and XML injection.
38pub mod qrcode;
39/// ASCII sanitization for XML text content (replaces accented characters).
40pub mod sanitize;
41/// NF-e XML document type identification and XML-to-JSON conversion.
42pub mod standardize;
43/// Brazilian state IBGE code lookup tables and helpers.
44pub mod state_codes;
45/// SEFAZ status code constants and valid-status sets.
46pub mod status_codes;
47/// Internal tax element types used by tax computation modules.
48pub mod tax_element;
49/// IBS/CBS (Imposto sobre Bens e Servicos / Contribuicao sobre Bens e Servicos) XML generation.
50pub mod tax_ibs_cbs;
51/// ICMS tax computation and XML generation (CST and CSOSN variants).
52pub mod tax_icms;
53/// IS (Imposto Seletivo) XML generation.
54pub mod tax_is;
55/// ISSQN (municipal service tax) XML generation.
56pub mod tax_issqn;
57/// PIS, COFINS, IPI, and II tax computation and XML generation.
58pub mod tax_pis_cofins_ipi;
59/// Timezone lookup by Brazilian state (UF).
60pub mod timezone;
61/// Public data structures for NF-e / NFC-e documents.
62pub mod types;
63/// Typestate XML builder for NF-e / NFC-e documents.
64pub mod xml_builder;
65/// XML building primitives: `tag`, `escape_xml`, and `extract_xml_tag_value`.
66pub mod xml_utils;
67
68/// Sealed trait infrastructure for preventing external implementations.
69pub mod sealed;
70/// Sealed public traits: [`TaxCalculation`](traits::TaxCalculation) and [`XmlSerializable`](traits::XmlSerializable).
71pub mod traits;