Browse Source

[FIX] Fix patch method for inutilizacao - wrong merge

pull/207/head
Danimar Ribeiro 7 years ago
parent
commit
405d889ee5
  1. 7
      pytrustnfe/nfe/__init__.py
  2. 22
      pytrustnfe/nfe/patch.py
  3. 2
      setup.py

7
pytrustnfe/nfe/__init__.py

@ -6,7 +6,7 @@
import os
import requests
from lxml import etree
from .patch import nfeInutilizacaoCE, has_patch
from .patch import has_patch
from .assinatura import Assinatura
from pytrustnfe.xml import render_xml, sanitize_response
from pytrustnfe.utils import gerar_chave, ChaveNFe
@ -90,8 +90,9 @@ def _send(certificado, method, **kwargs):
base_url = localizar_url(
method, kwargs['estado'], kwargs['modelo'], kwargs['ambiente'])
session = _get_session(certificado)
if has_patch:
return nfeInutilizacaoCE(session, xml_send)
patch = has_patch(kwargs['estado'], method)
if patch:
return patch(session, xml_send)
transport = Transport(session=session)
first_op, client = _get_client(base_url, transport)
return _send_zeep(first_op, client, xml_send)

22
pytrustnfe/nfe/patch.py

@ -1,15 +1,6 @@
from ..Servidores import SIGLA_ESTADO
from pytrustnfe.xml import sanitize_response
methods = [
'nfeInutilizacaoCE']
def has_patch(cod_estado, metodo):
uf = SIGLA_ESTADO[cod_estado]
method = metodo+uf
return method in methods
def nfeInutilizacaoCE(session, xml_send):
soap = '<Envelope xmlns="http://www.w3.org/2003/05/soap-envelope"><Body>\
@ -28,3 +19,16 @@ def nfeInutilizacaoCE(session, xml_send):
'received_xml': response,
'object': obj.Body.getchildren()[0]
}
methods = {
'NfeInutilizacaoCE': nfeInutilizacaoCE
}
def has_patch(cod_estado, metodo):
uf = SIGLA_ESTADO[cod_estado]
method = metodo+uf
if method in methods:
return methods[method]
return None

2
setup.py

@ -2,7 +2,7 @@
from setuptools import setup, find_packages
VERSION = "1.0.29"
VERSION = "1.0.30"
setup(

Loading…
Cancel
Save