Browse Source

Tentativa de corrigir a assinatura do xml

tags/0.1.5
Danimar 9 years ago
parent
commit
2a2bd6137c
  1. 4
      pytrustnfe/Servidores.py
  2. 4
      pytrustnfe/nfe/__init__.py
  3. 4
      pytrustnfe/nfe/assinatura.py
  4. 6
      pytrustnfe/nfe/templates/NfeAutorizacao.xml
  5. 1
      pytrustnfe/xml/__init__.py

4
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',

4
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<!DOCTYPE NFe [\n<!ATTLIST infNFe Id ID #IMPLIED>\n]>\n', '')
print xml_send
xml_send = xml_send.replace('\n', '')
xml_send = xml_send.replace('\n', u'')
xml_send = xml_send.replace('<?xml version="1.0"?>', '')
url = localizar_url(method, kwargs['estado'], kwargs['ambiente'])
cabecalho = _build_header(method, **kwargs)

4
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)

6
pytrustnfe/nfe/templates/NfeAutorizacao.xml

@ -122,6 +122,12 @@
<vCredICMSSN>{{ imposto.ICMS.vCredICMSSN }}</vCredICMSSN>
</ICMSSN101>
{% endif %}
{% if imposto.ICMS.CST == '102' -%}
<ICMSSN102>
<orig>{{ imposto.ICMS.orig }}</orig>
<CSOSN>{{ imposto.ICMS.CST }}</CSOSN>
</ICMSSN102>
{% endif %}
</ICMS>
<IPI>
<cEnq>{{ imposto.IPI.cEnq }}</cEnq>

1
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('&', '&amp;')
parser = etree.XMLParser(remove_blank_text=True, remove_comments=True)
elem = etree.fromstring(xml, parser=parser)
return etree.tostring(elem)

Loading…
Cancel
Save