pub fn attach_cancellation(
nfe_proc_xml: &str,
cancel_event_xml: &str,
) -> Result<String, FiscalError>Expand description
Attach a cancellation event response to an authorized <nfeProc> XML,
marking the NF-e as locally cancelled.
This mirrors the PHP Complements::cancelRegister() method. The function
searches the cancel_event_xml for <retEvento> elements whose:
cStatis in[135, 136, 155](valid cancellation statuses)tpEventois110111(cancellation) or110112(cancellation by substitution)chNFematches the access key in the authorized NF-e’s<protNFe>
When a matching <retEvento> is found, it is appended inside the
<nfeProc> element (before the closing </nfeProc> tag).
If no matching cancellation event is found, the original NF-e XML is returned unchanged (same behavior as the PHP implementation).
§Arguments
nfe_proc_xml- The authorized NF-e XML containing<nfeProc>with<protNFe>.cancel_event_xml- The SEFAZ cancellation event response XML containing<retEvento>.
§Errors
Returns FiscalError::XmlParsing if:
- The
nfe_proc_xmldoes not contain<protNFe>(not an authorized NF-e) - The
<protNFe>does not contain<chNFe>