fiscal_core/status_codes.rs
1//! SEFAZ status code constants (`cStat`) and valid-status sets.
2//!
3//! The [`sefaz_status`] submodule exposes named constants for the most common
4//! response codes from the SEFAZ web services. The [`VALID_PROTOCOL_STATUSES`]
5//! and [`VALID_EVENT_STATUSES`] slices are used by [`crate::complement`] to
6//! validate responses before attaching protocols.
7
8/// SEFAZ status code constants (`cStat`) used across the fiscal module.
9///
10/// Reference: Manual de Orientação do Contribuinte (MOC) v7.0+
11pub mod sefaz_status {
12 /// 100 -- Authorized (Autorizado o uso da NF-e)
13 pub const AUTHORIZED: &str = "100";
14 /// 101 -- Cancelled
15 pub const CANCELLED: &str = "101";
16 /// 102 -- Number voided (Inutilizacao de numero homologada)
17 pub const VOIDED: &str = "102";
18 /// 107 -- Service running (Servico em Operacao)
19 pub const SERVICE_RUNNING: &str = "107";
20 /// 110 -- Usage denied (Uso Denegado)
21 pub const DENIED: &str = "110";
22 /// 135 -- Event registered and linked to NF-e
23 pub const EVENT_REGISTERED: &str = "135";
24 /// 136 -- Event registered but not linked to NF-e
25 pub const EVENT_ALREADY_REGISTERED: &str = "136";
26 /// 150 -- Authorized (late / fora do prazo)
27 pub const AUTHORIZED_LATE: &str = "150";
28 /// 155 -- Already cancelled (late)
29 pub const ALREADY_CANCELLED: &str = "155";
30 /// 204 -- Duplicate
31 pub const DUPLICATE: &str = "204";
32 /// 205 -- Denied in SEFAZ database
33 pub const DENIED_IN_DATABASE: &str = "205";
34 /// 301 -- Denied: issuer fiscal irregularity
35 pub const DENIED_ISSUER_IRREGULAR: &str = "301";
36 /// 302 -- Denied: recipient fiscal irregularity
37 pub const DENIED_RECIPIENT_IRREGULAR: &str = "302";
38 /// 303 -- Denied: recipient not enabled in UF
39 pub const DENIED_RECIPIENT_NOT_ENABLED: &str = "303";
40}
41
42/// Valid status codes for protocol attachment.
43///
44/// These statuses indicate the NF-e was processed (authorized or denied)
45/// and the protocol can be attached to form `nfeProc`.
46pub const VALID_PROTOCOL_STATUSES: &[&str] = &[
47 "100", // Authorized
48 "150", // Authorized (late)
49 "110", // Usage denied
50 "205", // Denied in database
51 "301", // Denied: issuer irregular
52 "302", // Denied: recipient irregular
53 "303", // Denied: recipient not enabled
54];
55
56/// Valid status codes for event attachment.
57///
58/// These statuses indicate the event was accepted and can be attached
59/// to form `procEventoNFe`.
60pub const VALID_EVENT_STATUSES: &[&str] = &[
61 "135", // Event registered
62 "136", // Event registered (unlinked)
63 "155", // Already cancelled (late)
64];