The processed CT-e documents that are archived and delivered, assembled the
way SefazNfe.Proc assembles the NF-e's (NFePHP Complements), and under the
same rules (AD-011): the signed document and SEFAZ's answer are copied byte
for byte out of what the caller passed and wrapped, never parsed and written
back. The wrapper declares the CT-e namespace, which the answer's elements
inherit from the SOAP body they were cut from.
| Function | Result | Parts |
|---|---|---|
cte_proc/2 | cteProc (cteOSProc for a CTeOS) | CTe + protCTe |
cte_event_proc/2 | procEventoCTe | eventoCTe + retEventoCTe |
cte_cancel_register/2 | the same cteProc | + the cancellation's retEventoCTe |
Each returns {:ok, xml} or {:error, reason}, with the reasons
SefazNfe.Proc documents (:no_protocol, :no_event_return,
:key_mismatch, :digest_mismatch, {:not_accepted, c_stat},
{:not_a_cancellation, tp_evento}, {:xml, reason}), plus
:not_a_cte_proc for cte_cancel_register/2 of something else.
What is checked
cte_proc/2: theprotCTewhosechCTeis the document's key (IdofinfCtewithoutCTe) and, when both carry one, whosedigValis the document'sDigestValue;cStat100, 150, 110, 205 or 301 (authorized and denied, NFePHP's list; 301 only for a CT-e, never a CT-e OS). A CT-e OS (CTeOS) becomes acteOSProc.cte_event_proc/2: theretEventoCTeof the samechCTeandtpEvento;cStat134, 135 or 136, and 155 for a cancellation (110111). 134 is not in NFePHP's list: the MOC homologates the event under it too (registered with a warning about the CT-e's situation), so it is archived.cte_cancel_register/2:cStat135, 136 or 155,tpEvento110111 and thechCTeof thecteProc.
Summary
Functions
Marks an authorized cteProc as cancelled by appending the cancellation's
retEventoCTe after its protCTe (NFePHP's cancelRegister).
procEventoCTe: the signed eventoCTe and the retEventoCTe SEFAZ answered
it with.
cteProc (or cteOSProc): the signed CTe and its protCTe, from the
answer of the authorization or of a consultation.
Types
@type reason() :: term()
Functions
Marks an authorized cteProc as cancelled by appending the cancellation's
retEventoCTe after its protCTe (NFePHP's cancelRegister).
event_xml is the procEventoCTe from cte_event_proc/2 or SEFAZ's answer
itself; the first retEventoCTe that is an accepted cancellation (110111) of
the cteProc's key is the one appended, spliced as received. Registering the
same retEventoCTe again returns the cteProc unchanged. Unlike NFePHP, an
answer that does not qualify is an error that says why.
procEventoCTe: the signed eventoCTe and the retEventoCTe SEFAZ answered
it with.
cteProc (or cteOSProc): the signed CTe and its protCTe, from the
answer of the authorization or of a consultation.