| adjustNfeForContingency | Adjust NF-e XML for contingency mode. |
| attachB2B | Attach a B2B financial tag to an authorized nfeProc XML. Wraps the nfeProc and B2B content in a <nfeProcB2B> element. |
| attachB2bTag | Build b2b tag for nfeProc. |
| attachCancellation | Attach a cancellation event response to an authorized nfeProc XML. Appends the <retEvento> node inside the <nfeProc> wrapper. |
| attachEventProtocol | Attach an event protocol response to the event request, producing the procEventoNFe wrapper. |
| attachInutilizacao | Attach the SEFAZ inutilizacao response to the request, producing the ProcInutNFe wrapper. |
| attachProtocol | Attach the SEFAZ authorization protocol to a signed NFe XML, producing the nfeProc wrapper required for storage and DANFE. |
| buildAccessKey | Build the access key (chave de acesso) -- 44 digits. Delegates to AccessKey.build(); kept for backward compatibility. |
| buildAccessKeyQueryXml | Build access key query request XML (consSitNFe). |
| buildAceiteDebito | tpEvento=211128 -- Debit acceptance in tax assessment |
| buildApropriacaoCreditoBens | tpEvento=211150 -- Goods and services credit appropriation request |
| buildApropriacaoCreditoComb | tpEvento=211140 -- Fuel credit appropriation request |
| buildAtualizacaoDataEntrega | tpEvento=112150 -- Update estimated delivery date |
| buildAuthorizationRequestXml | Build the authorization request XML (envelope for sending an NF-e). |
| buildBatchEventXml | Build batch event XML (generic, multiple events in one envelope). |
| buildBatchManifestationXml | Build batch manifestation XML (multiple events in one envelope). |
| buildBatchSubmissionXml | Build batch submission request XML (enviNFe). |
| buildCadastroQueryXml | Build cadastro query request XML (ConsCad). |
| buildCancelaEvento | tpEvento=110001 -- Event cancellation (cancel a previously registered event) |
| buildCancellationEventXml | Build cancellation event XML (using the generic event builder). |
| buildCancellationXml | Build cancellation event XML. |
| buildCCeXml | Build Carta de Correcao (CCe) event XML. |
| buildCofinsStXml | Build COFINS-ST XML string (backward-compatible wrapper). |
| buildCofinsXml | Build COFINS XML string (backward-compatible wrapper). |
| buildConciliacaoXml | Build conciliation event XML. |
| buildCscXml | Build CSC admin request XML (admCscNFCe). |
| buildDeliveryFailureCancellationXml | Build delivery failure cancellation event XML. |
| buildDeliveryFailureXml | Build delivery failure event XML (Insucesso na Entrega da NF-e). |
| buildDeliveryProofCancellationXml | Build delivery proof cancellation event XML. |
| buildDeliveryProofXml | Build delivery proof event XML (Comprovante de Entrega da NF-e). |
| buildDestinoConsumoPessoal | tpEvento=211120 -- Item destination for personal consumption |
| buildDistDFeQueryXml | Build DFe distribution query XML (distDFeInt). |
| buildEpecNfceStatusXml | Build consStatServ XML for EPEC NFC-e status check. |
| buildEpecNfceXml | Build EPEC event XML for an NFC-e (model 65). |
| buildEpecStatusXml | Build EPEC NFC-e status request XML (same as status but for EPEC service). |
| buildEventId | Build an event ID: ID{tpEvento}{chNFe}{seqPadded} |
| buildEventXml | Build a generic SEFAZ event XML (evento inside envEvento). This produces the unsigned inner evento XML. Signing is done separately. |
| buildExtensionCancellationXml | Build ECPP (cancel extension request) event XML. |
| buildExtensionRequestXml | Build EPP (extension request) event XML. |
| buildFornecimentoNaoRealizado | tpEvento=112140 -- Unfulfilled supply with prepayment |
| buildIcmsPartXml | Build the ICMSPart XML group (partition between states). Used inside <ICMS> for CST 10 or 90 with interstate partition. |
| buildIcmsStXml | Build the ICMSST XML group (ST repasse). Used inside <ICMS> for CST 41 or 60 with interstate ST repasse. |
| buildIcmsUfDestXml | Build the ICMSUFDest XML group (interstate to final consumer). This is a sibling of <ICMS>, placed directly inside <imposto>. |
| buildIcmsXml | Build ICMS XML string (backward-compatible wrapper around calculateIcms). |
| buildIiXml | Build II (import tax) XML string (backward-compatible wrapper). |
| buildImobilizacaoItem | tpEvento=211130 -- Item immobilization (fixed asset registration) |
| buildImportacaoZFM | tpEvento=112120 -- ALC/ZFM import not converted to exemption |
| buildImpostoDevol | Build impostoDevol XML string (backward-compatible wrapper). |
| buildInfoPagtoIntegral | tpEvento=112110 -- Full payment confirmation event Ported from PHP TraitEventsRTC::sefazInfoPagtoIntegral() |
| buildInfoPagtoIntegralXml | Build info pagamento integral event XML (tpEvento 112110). |
| buildInterestedActorXml | Build Ator Interessado event XML. |
| buildInvoiceXml | Build a complete NF-e or NFC-e XML (unsigned). The XML follows layout 4.00 as defined by MOC. |
| buildIpiXml | Build IPI XML string (backward-compatible wrapper). |
| buildIssqnXml | Build ISSQN XML string and accumulate totals (backward-compatible wrapper). |
| buildIsXml | Build IS XML string (backward-compatible wrapper). |
| buildManifestacaoTransfCredCBS | tpEvento=212120 -- Manifestation on CBS credit transfer request |
| buildManifestacaoTransfCredIBS | tpEvento=212110 -- Manifestation on IBS credit transfer request |
| buildManifestationXml | Build recipient manifestation event XML. |
| buildNfceConsultUrl | Build the NFC-e urlChave tag content for consulting the NFe by access key. |
| buildNfceQrCodeUrl | Build the NFC-e QR Code URL. |
| buildPisStXml | Build PIS-ST XML string (backward-compatible wrapper). |
| buildPisXml | Build PIS XML string (backward-compatible wrapper). |
| buildReceiptQueryXml | Build receipt query request XML (consReciNFe). |
| buildRouboPerdaTransporteAdquirente | tpEvento=211124 -- Perishment, loss, theft by acquirer (FOB) |
| buildRouboPerdaTransporteFornecedor | tpEvento=112130 -- Perishment, loss, theft by supplier (CIF) |
| buildSolApropCredPresumido | tpEvento=211110 -- Deemed credit appropriation request |
| buildStatusRequestXml | Build the status service request XML. |
| buildSubstitutionCancellationXml | Build substitution cancellation event XML (for NFC-e model 65 only). |
| buildTestNfceXml | Build a minimal NFC-e XML for testing EPEC. |
| buildVoidingXml | Build number voiding (inutilizacao) request XML. |
| calculateCofins | Calculate COFINS tax element (domain logic, no XML). |
| calculateCofinsSt | Calculate COFINS-ST tax element (domain logic, no XML). |
| calculateIcms | Calculate ICMS for a single item (domain logic, no XML dependency). Returns structured TaxElement + accumulated totals. |
| calculateIi | Calculate II (import tax) element (domain logic, no XML). |
| calculateImpostoDevol | Calculate impostoDevol element (domain logic, no XML). |
| calculateIpi | Calculate IPI tax element (domain logic, no XML). |
| calculateIs | Calculate IS tax element (domain logic, no XML dependency). Three mutually exclusive modes based on which fields are present. |
| calculateIssqn | Calculate ISSQN tax element and accumulate totals (domain logic, no XML). |
| calculatePis | Calculate PIS tax element (domain logic, no XML). |
| calculatePisSt | Calculate PIS-ST tax element (domain logic, no XML). |
| checkRtcModel | Validate that the model is 55 (NFe) and the access key also indicates model 55. RTC events only apply to model 55. Ported from PHP TraitEventsRTC::checkModel(). |
| createIcmsTotals | Create a zeroed-out ICMS totals object. |
| createIssqnTotals | Create a zeroed-out ISSQN totals object. |
| defaultLotId | Generate lot ID from explicit value or Date.now() fallback |
| escapeXml | Escape special XML characters in text content and attribute values |
| extractCertFromPfx | Extract certificate PEM from PFX using openssl CLI (with -legacy flag). |
| extractKeyFromPfx | Extract private key PEM from PFX using openssl CLI (with -legacy flag). |
| extractXmlTagValue | Extract text content of a simple XML tag from a raw XML string |
| filterFields | Filter null entries from a TaxField array |
| formatCents | Format cents integer to decimal string. E.g. 1050 -> "10.50" |
| formatCentsOrNull | Format cents to decimal string, returning null for null/undefined input |
| formatCentsOrZero | Format cents to decimal string, defaulting to "0.00" for null/undefined |
| formatDateTimeBR | Format a Date as ISO 8601 with Brazil timezone offset. SEFAZ rejects UTC "Z" suffix -- requires explicit offset like -03:00. |
| formatDecimal | Format a number with N decimal places |
| formatRate | Format rate stored as hundredths to decimal string. E.g. 1800 -> "18.0000" |
| formatRate4 | Format rate stored as value * 10000 to 4-decimal string. E.g. 16500 -> "1.6500" |
| formatRate4OrZero | Format rate4 (value * 10000) to 4-decimal string, defaulting to "0.0000" for null/undefined |
| getCertificateInfo | Extract certificate info for display (without exposing private key). |
| getContingencyType | Get the contingency type for a given state. |
| getEventDescription | Map event type to its description |
| getNfceConsultationUri | Get the NFC-e consultation URI (urlChave) for a given state and environment. Used for QR Code and DANFCE consultation links. |
| getSefazUrl | Get the SEFAZ web service URL for a given state, service, environment and model. |
| getStateByCode | Get the UF abbreviation for an IBGE numeric code. |
| getStateCode | Get the IBGE numeric code for a state abbreviation. |
| getStructure | Get the appropriate structure for the given version and layout. |
| getStructureByVersionString | Get the appropriate structure for parsing, using a version string like "4.00" or "3.10". |
| isValidGtin | Validate a GTIN-8/12/13/14 barcode number. |
| isValidTxt | Validate a TXT representation of an NFe. Returns an empty array if valid, or an array of error strings if invalid. |
| loadCertificate | Load private key and certificate from a PFX/PKCS12 buffer. |
| loadStructure | Load the TXT structure definition for the given version and layout. |
| lookupCep | Lookup address by CEP using ViaCEP with BrasilAPI as fallback. |
| mergeIcmsTotals | Merge item-level ICMS totals into an accumulator. |
| optionalField | Helper: create an optional field (returns null if value is nullish) |
| parseAuthorizationResponse | Parse authorization response (NfeAutorizacao / NfeRetAutorizacao). |
| parseCancellationResponse | Parse cancellation event response. |
| parseStatusResponse | Parse the SEFAZ service status response (NfeStatusServico). |
| putQRTag | Insert QR Code and urlChave tags into a signed NFC-e XML. |
| requiredField | Helper: create a required field (throws if value is nullish) |
| resolveVerAplic | Resolve verAplic: explicit > config > default "4.00" |
| sefazRequest | Send a SOAP 1.2 request to a SEFAZ web service with mutual TLS (client certificate). Uses curl with PEM cert/key extracted from PFX, because Bun's node:https does not fully support mTLS with PFX (ECONNREFUSED on Agent with pfx option). |
| serializeTaxElement | Serialize a TaxElement to an XML string. |
| signEventXml | Sign a SEFAZ event XML (cancelamento, CCe, etc.) with XMLDSig. Same as signXml() but references inside . |
| signXml | Sign an NF-e XML string with XMLDSig enveloped signature using xml-crypto. Covers with C14N canonicalization, SHA-1 digest, RSA-SHA1 signature. |
| tag | Build an XML tag with optional attributes and children. |
| toArray | Convert an NFe XML string to a plain object (like PHP's toArray). |
| toJson | Convert an NFe XML string to a JSON string. |
| toStd | Convert an NFe XML string to a normalized object (like PHP's toStd). In TypeScript this is equivalent to toArray since we don't have stdClass. |
| validate | Validate a fiscal configuration JSON string. Returns the parsed config object on success, throws on failure. |
| validateAccessKey | Validate access key format and throw if invalid. |
| whichIs | Identify which NFe document type an XML string represents. |