Browse Source

Template de cancelamento e assinando o cancelamento

pull/9/head
Danimar 9 years ago
parent
commit
e9676e0836
  1. 8
      pytrustnfe/nfe/__init__.py
  2. 22
      pytrustnfe/nfe/templates/RecepcaoEventoCancelamento.xml

8
pytrustnfe/nfe/__init__.py

@ -71,8 +71,12 @@ def _send(certificado, method, sign, **kwargs):
xmlElem_send = _add_required_node(xmlElem_send) xmlElem_send = _add_required_node(xmlElem_send)
signer = Assinatura(certificado.pfx, certificado.password) signer = Assinatura(certificado.pfx, certificado.password)
xml_send = signer.assina_xml(
xmlElem_send, kwargs['NFes'][0]['infNFe']['Id'])
if method == 'NfeAutorizacao':
xml_send = signer.assina_xml(
xmlElem_send, kwargs['NFes'][0]['infNFe']['Id'])
elif method == 'RecepcaoEventoCancelamento':
xml_send = signer.assina_xml(
xmlElem_send, kwargs['eventos'][0]['Id'])
else: else:
xml_send = etree.tostring(xmlElem_send) xml_send = etree.tostring(xmlElem_send)

22
pytrustnfe/nfe/templates/RecepcaoEventoCancelamento.xml

@ -1,20 +1,22 @@
<envEvento xmlns="http://www.portalfiscal.inf.br/nfe" versao="1.00"> <envEvento xmlns="http://www.portalfiscal.inf.br/nfe" versao="1.00">
<idLote>{{ obj.lote }}</idLote>
<idLote>{{ idLote }}</idLote>
{% for evento in eventos %}
<evento xmlns="http://www.portalfiscal.inf.br/nfe" versao="1.00"> <evento xmlns="http://www.portalfiscal.inf.br/nfe" versao="1.00">
<infEvento Id="{{ obj.id }}">
<cOrgao>{{ obj.orgao }}</cOrgao>
<tpAmb>{{ obj.ambiente }}</tpAmb>
<CNPJ>{{ obj.cnpj }}</CNPJ>
<chNFe>{{ obj.chave_nfe }}</chNFe>
<dhEvento>{{ obj.data_hora_evento }}</dhEvento>
<infEvento Id="{{ evento.Id }}">
<cOrgao>{{ evento.cOrgao }}</cOrgao>
<tpAmb>{{ evento.tpAmb }}</tpAmb>
<CNPJ>{{ evento.CNPJ }}</CNPJ>
<chNFe>{{ evento.chNFe }}</chNFe>
<dhEvento>{{ evento.dhEvento }}</dhEvento>
<tpEvento>110111</tpEvento> <tpEvento>110111</tpEvento>
<nSeqEvento>{{ obj.numero_evento }}</nSeqEvento>
<nSeqEvento>{{ evento.nSeqEvento }}</nSeqEvento>
<verEvento>1.00</verEvento> <verEvento>1.00</verEvento>
<detEvento versao="1.00"> <detEvento versao="1.00">
<descEvento>Cancelamento</descEvento> <descEvento>Cancelamento</descEvento>
<nProt>{{ obj.protocolo }}</nProt>
<xJust>{{obj.justificativa }}</xJust>
<nProt>{{ evento.nProt }}</nProt>
<xJust>{{ evento.xJust }}</xJust>
</detEvento> </detEvento>
</infEvento> </infEvento>
</evento> </evento>
{% endfor %}
</envEvento> </envEvento>
Loading…
Cancel
Save