From 2a2bd6137c3a6fe46de09ccab1e0bee16999976c Mon Sep 17 00:00:00 2001 From: Danimar Date: Mon, 12 Sep 2016 00:47:41 -0300 Subject: [PATCH] Tentativa de corrigir a assinatura do xml --- pytrustnfe/Servidores.py | 4 ++-- pytrustnfe/nfe/__init__.py | 4 ++-- pytrustnfe/nfe/assinatura.py | 4 ++-- pytrustnfe/nfe/templates/NfeAutorizacao.xml | 6 ++++++ pytrustnfe/xml/__init__.py | 1 - 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/pytrustnfe/Servidores.py b/pytrustnfe/Servidores.py index 5eb475e..6d24b6b 100644 --- a/pytrustnfe/Servidores.py +++ b/pytrustnfe/Servidores.py @@ -121,7 +121,7 @@ SVRS = { WS_NFE_SITUACAO : 'ws/NfeStatusServico/NfeStatusServico2.asmx', }, NFE_AMBIENTE_HOMOLOGACAO: { - 'servidor' : 'homologacao.nfe.sefazvirtual.rs.gov.br', + 'servidor' : 'nfe-homologacao.svrs.rs.gov.br', WS_NFE_RECEPCAO_EVENTO: 'ws/recepcaoevento/recepcaoevento.asmx', WS_NFE_AUTORIZACAO : 'ws/NfeAutorizacao/NfeAutorizacao.asmx', WS_NFE_CONSULTA_AUTORIZACAO : 'ws/NfeRetAutorizacao/NfeRetAutorizacao.asmx', @@ -471,7 +471,7 @@ UFRS = { WS_NFE_SITUACAO : 'ws/NfeStatusServico/NfeStatusServico2.asmx', }, NFE_AMBIENTE_HOMOLOGACAO: { - 'servidor' : 'homologacao.nfe.sefaz.rs.gov.br', + 'servidor' : 'nfe-homologacao.sefazrs.rs.gov.br', WS_NFE_RECEPCAO_EVENTO : 'ws/recepcaoevento/recepcaoevento.asmx', WS_NFE_AUTORIZACAO : 'ws/NfeAutorizacao/NFeAutorizacao.asmx', WS_NFE_CONSULTA_AUTORIZACAO : 'ws/NfeRetAutorizacao/NFeRetAutorizacao.asmx', diff --git a/pytrustnfe/nfe/__init__.py b/pytrustnfe/nfe/__init__.py index 581221b..6b75a6a 100644 --- a/pytrustnfe/nfe/__init__.py +++ b/pytrustnfe/nfe/__init__.py @@ -57,8 +57,8 @@ def _send(certificado, method, sign, **kwargs): xml_send, kwargs['NFes'][0]['infNFe']['Id']) xml_send = xml_send.replace( '\n\n]>\n', '') - print xml_send - xml_send = xml_send.replace('\n', '') + xml_send = xml_send.replace('\n', u'') + xml_send = xml_send.replace('', '') url = localizar_url(method, kwargs['estado'], kwargs['ambiente']) cabecalho = _build_header(method, **kwargs) diff --git a/pytrustnfe/nfe/assinatura.py b/pytrustnfe/nfe/assinatura.py index ad531b0..de5044e 100644 --- a/pytrustnfe/nfe/assinatura.py +++ b/pytrustnfe/nfe/assinatura.py @@ -39,7 +39,7 @@ class Assinatura(object): self._inicializar_cripto() try: doc_xml = libxml2.parseMemory( - xml, len(xml)) + xml.encode('utf-8'), len(xml.encode('utf-8'))) signNode = xmlsec.TmplSignature(doc_xml, xmlsec.transformInclC14NId(), @@ -92,7 +92,7 @@ class Assinatura(object): self._inicializar_cripto() try: doc_xml = libxml2.parseMemory( - xml, len(xml)) + xml.encode('utf-8'), len(xml.encode('utf-8'))) signNode = xmlsec.TmplSignature(doc_xml, xmlsec.transformInclC14NId(), xmlsec.transformRsaSha1Id(), None) diff --git a/pytrustnfe/nfe/templates/NfeAutorizacao.xml b/pytrustnfe/nfe/templates/NfeAutorizacao.xml index 7844783..28c5905 100644 --- a/pytrustnfe/nfe/templates/NfeAutorizacao.xml +++ b/pytrustnfe/nfe/templates/NfeAutorizacao.xml @@ -122,6 +122,12 @@ {{ imposto.ICMS.vCredICMSSN }} {% endif %} + {% if imposto.ICMS.CST == '102' -%} + + {{ imposto.ICMS.orig }} + {{ imposto.ICMS.CST }} + + {% endif %} {{ imposto.IPI.cEnq }} diff --git a/pytrustnfe/xml/__init__.py b/pytrustnfe/xml/__init__.py index 792bc21..561d3b5 100644 --- a/pytrustnfe/xml/__init__.py +++ b/pytrustnfe/xml/__init__.py @@ -25,7 +25,6 @@ def render_xml(path, template_name, **nfe): template = env.get_template(template_name) xml = template.render(**nfe) - xml = xml.replace('&', '&') parser = etree.XMLParser(remove_blank_text=True, remove_comments=True) elem = etree.fromstring(xml, parser=parser) return etree.tostring(elem)