SefazNfe.DistDFe (sefaz_nfe v0.1.0)

Copy Markdown View Source

Page returned by NFeDistribuicaoDFe (Ambiente Nacional).

The cursor belongs to the caller (AD-002): persist ult_nsu and pass it back, or the same documents arrive forever. max_nsu says how far the AN has gone, so ult_nsu < max_nsu means there is a backlog to drain.

Summary

Functions

Parses a retDistDFeInt response.

Types

t()

@type t() :: %SefazNfe.DistDFe{
  c_stat: pos_integer(),
  documents: [SefazNfe.DistDFe.Document.t()],
  max_nsu: String.t(),
  ult_nsu: String.t(),
  x_motivo: String.t()
}

Functions

parse(body)

@spec parse(String.t()) :: {:ok, t()} | {:error, term()}

Parses a retDistDFeInt response.

Every document arrives gzipped and base64 encoded. A payload that will not decode is an error rather than a silently dropped document (SEFAZ-07): losing an inbound NF-e without noticing is worse than failing the whole page, since the cursor would move past it.

cStat 137 (no document found) is a normal empty page, and 656 (consumo indevido) arrives as a page too, so the caller can back off on it.