|
|
|
@ -1,4 +1,6 @@ |
|
|
|
# -*- coding: utf-8 -*- |
|
|
|
# Copyright (C) 2018 - TODAY Luis Felipe Mileo - KMEE INFORMATICA LTDA |
|
|
|
# License AGPL-3 - See https://www.gnu.org/licenses/lgpl-3.0.html |
|
|
|
|
|
|
|
from __future__ import division, print_function, unicode_literals |
|
|
|
|
|
|
|
@ -23,12 +25,13 @@ from pynfe.utils.webservices import ( |
|
|
|
) |
|
|
|
from pynfe.utils import etree |
|
|
|
from .comunicacao import ComunicacaoSefaz |
|
|
|
from .resposta import analisar_retorno |
|
|
|
|
|
|
|
from mdfelib.v3_00.consStatServMDFe import TConsStatServ |
|
|
|
from mdfelib.v3_00.consSitMDFe import TConsSitMDFe |
|
|
|
from mdfelib.v3_00.consMDFeNaoEnc import TConsMDFeNaoEnc |
|
|
|
from mdfelib.v3_00.enviMDFe import TEnviMDFe |
|
|
|
from mdfelib.v3_00.consReciMDFe import TConsReciMDFe |
|
|
|
from mdfelib.v3_00 import consStatServMDFe |
|
|
|
from mdfelib.v3_00 import consSitMDFe |
|
|
|
from mdfelib.v3_00 import consMDFeNaoEnc |
|
|
|
from mdfelib.v3_00 import enviMDFe |
|
|
|
from mdfelib.v3_00 import consReciMDFe |
|
|
|
|
|
|
|
|
|
|
|
class ComunicacaoMDFE(ComunicacaoSefaz): |
|
|
|
@ -55,7 +58,7 @@ class ComunicacaoMDFE(ComunicacaoSefaz): |
|
|
|
WS_MDFE_STATUS_SERVICO |
|
|
|
) |
|
|
|
|
|
|
|
raiz = TConsStatServ( |
|
|
|
raiz = consStatServMDFe.TConsStatServ( |
|
|
|
versao=self._versao, |
|
|
|
tpAmb=str(self._ambiente), |
|
|
|
xServ='STATUS', |
|
|
|
@ -67,15 +70,16 @@ class ComunicacaoMDFE(ComunicacaoSefaz): |
|
|
|
self._construir_etree_ds(raiz) |
|
|
|
) |
|
|
|
|
|
|
|
return self._post( |
|
|
|
retorno = self._post( |
|
|
|
url, xml, soap_webservice_method=webservice + b'/' + metodo |
|
|
|
) |
|
|
|
return analisar_retorno(retorno, consStatServMDFe) |
|
|
|
|
|
|
|
def consulta(self, chave): |
|
|
|
url, webservice, metodo = self._get_url_webservice_metodo( |
|
|
|
WS_MDFE_CONSULTA |
|
|
|
) |
|
|
|
raiz = TConsSitMDFe( |
|
|
|
raiz = consSitMDFe.TConsSitMDFe( |
|
|
|
versao=self._versao, |
|
|
|
tpAmb=str(self._ambiente), |
|
|
|
xServ='CONSULTAR', |
|
|
|
@ -86,15 +90,16 @@ class ComunicacaoMDFE(ComunicacaoSefaz): |
|
|
|
webservice, |
|
|
|
self._construir_etree_ds(raiz) |
|
|
|
) |
|
|
|
return self._post( |
|
|
|
retorno = self._post( |
|
|
|
url, xml, soap_webservice_method=webservice + b'/' + metodo |
|
|
|
) |
|
|
|
return analisar_retorno(retorno, consSitMDFe) |
|
|
|
|
|
|
|
def consulta_nao_encerrados(self, cnpj): |
|
|
|
url, webservice, metodo = self._get_url_webservice_metodo( |
|
|
|
WS_MDFE_CONSULTA_NAO_ENCERRADOS |
|
|
|
) |
|
|
|
raiz = TConsMDFeNaoEnc( |
|
|
|
raiz = consMDFeNaoEnc.TConsMDFeNaoEnc( |
|
|
|
versao=self._versao, |
|
|
|
tpAmb=str(self._ambiente), |
|
|
|
xServ='CONSULTAR NÃO ENCERRADOS', |
|
|
|
@ -105,16 +110,17 @@ class ComunicacaoMDFE(ComunicacaoSefaz): |
|
|
|
webservice, |
|
|
|
self._construir_etree_ds(raiz) |
|
|
|
) |
|
|
|
return self._post( |
|
|
|
retorno = self._post( |
|
|
|
url, xml, soap_webservice_method=webservice + b'/' + metodo |
|
|
|
) |
|
|
|
return analisar_retorno(retorno, consMDFeNaoEnc) |
|
|
|
|
|
|
|
def autorizacao(self, str_documento_assinado, id_lote='1'): |
|
|
|
url, webservice, metodo = self._get_url_webservice_metodo( |
|
|
|
WS_MDFE_RECEPCAO |
|
|
|
) |
|
|
|
|
|
|
|
raiz = TEnviMDFe(versao=self._versao, idLote=id_lote) |
|
|
|
raiz = enviMDFe.TEnviMDFe(versao=self._versao, idLote=id_lote) |
|
|
|
raiz.original_tagname_ = 'enviMDFe' |
|
|
|
|
|
|
|
etree_ds = self._construir_etree_ds(raiz) |
|
|
|
@ -122,16 +128,17 @@ class ComunicacaoMDFE(ComunicacaoSefaz): |
|
|
|
|
|
|
|
xml = self._construir_xml_soap(webservice, etree_ds) |
|
|
|
|
|
|
|
return self._post( |
|
|
|
retorno = self._post( |
|
|
|
url, xml, soap_webservice_method=webservice + b'/' + metodo |
|
|
|
) |
|
|
|
return analisar_retorno(retorno, enviMDFe) |
|
|
|
|
|
|
|
def consulta_recibo(self, numero): |
|
|
|
url, webservice, metodo = self._get_url_webservice_metodo( |
|
|
|
WS_MDFE_RET_RECEPCAO |
|
|
|
) |
|
|
|
|
|
|
|
raiz = TConsReciMDFe( |
|
|
|
raiz = consReciMDFe.TConsReciMDFe( |
|
|
|
versao=self._versao, |
|
|
|
tpAmb=str(self._ambiente), |
|
|
|
nRec=numero, |
|
|
|
@ -141,6 +148,8 @@ class ComunicacaoMDFE(ComunicacaoSefaz): |
|
|
|
webservice, |
|
|
|
self._construir_etree_ds(raiz) |
|
|
|
) |
|
|
|
return self._post( |
|
|
|
retorno = self._post( |
|
|
|
url, xml, soap_webservice_method=webservice + b'/' + metodo |
|
|
|
) |
|
|
|
return analisar_retorno(retorno, consReciMDFe) |
|
|
|
|