SefazNfe.CTe.Supl (sefaz_nfe v0.5.0)

Copy Markdown View Source

infCTeSupl with the QR code (qrCodCTe), mandatory in CT-e 4.00 (MOC rule G212/rejeicao 850).

For a normal emission (and for SVC, which the MOC treats like it) the text is the on-line, signature-less form:

{qr_url}?chCTe={chave}&tpAmb={tpAmb}

qr_url is the portal of the authorizer serving the emitting UF (SefazNfe.Endpoints.cte_qr_code_url/2). Rejeicao 854 forbids a sign parameter outside contingency, so none is added.

The contingency forms that do carry &sign= (tpEmis 4, EPEC, and 5, FS-DA: a base64 RSA-SHA1 of the key, signed with the certificate) are not generated: SefazNfe.CTe does not route those emissions (AD-005) and put/3 answers {:error, {:unsupported, {:tp_emis, n}}} for them rather than a QR code SEFAZ would reject as 855.

Placement

infCTeSupl follows infCte/infCTeNorm and precedes Signature; it is not covered by the signature, whose only Reference is infCte's Id. It is spliced into the already signed bytes by byte offset, the way SefazNfe.NFCe.put_supl/4 does. A document that already carries one is returned as it is. The text is XML-escaped, which is the & of the query.

Summary

Functions

Makes sure the CT-e (or CT-e OS) xml carries an infCTeSupl.

The on-line QR code text: {qr_url}?chCTe={key}&tpAmb={tp_amb}.

Functions

put(xml, uf, environment)

@spec put(String.t(), String.t() | atom(), SefazNfe.Endpoints.environment()) ::
  {:ok, String.t()} | {:error, term()}

Makes sure the CT-e (or CT-e OS) xml carries an infCTeSupl.

uf is the emitting UF, which selects the portal; environment selects between the production and homologation tables. The key and tpAmb come from the document.

qr_code(qr_url, key, tp_amb)

@spec qr_code(String.t(), String.t(), String.t()) :: String.t()

The on-line QR code text: {qr_url}?chCTe={key}&tpAmb={tp_amb}.