diff --git a/pytrustnfe/nfe/__init__.py b/pytrustnfe/nfe/__init__.py index 0083b3c..f1bfc52 100644 --- a/pytrustnfe/nfe/__init__.py +++ b/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) diff --git a/pytrustnfe/nfe/patch.py b/pytrustnfe/nfe/patch.py index 8cb063f..6ca85ef 100644 --- a/pytrustnfe/nfe/patch.py +++ b/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 = '\ @@ -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 diff --git a/setup.py b/setup.py index 1b5c59d..3c07021 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup, find_packages -VERSION = "1.0.29" +VERSION = "1.0.30" setup(