From 76877482668dedebbc864ee1cf3a12a3ef6ea3c8 Mon Sep 17 00:00:00 2001 From: Junior Tada Date: Wed, 15 Jul 2015 02:50:22 -0300 Subject: [PATCH 1/3] implementado consulta status --- pynfe/__init__.py | 7 ++- pynfe/processamento/__init__.py | 5 +-- pynfe/processamento/comunicacao.py | 91 +++++++++++++++++--------------------- setup.py | 2 +- texte.xml | 4 +- 5 files changed, 49 insertions(+), 60 deletions(-) diff --git a/pynfe/__init__.py b/pynfe/__init__.py index 546296e..7d3cab9 100644 --- a/pynfe/__init__.py +++ b/pynfe/__init__.py @@ -1,8 +1,7 @@ def get_version(): - return '0.1' + return '0.2' __version__ = get_version() -__author__ = 'Marinho Brandao' +__author__ = 'Marinho Brandao, Junior Tada, Leonardo Tada' __license__ = 'GNU Lesser General Public License (LGPL)' -__url__ = 'http://github.com/marinho/PyNFe' - +__url__ = 'https://github.com/leotada/PyNFe' diff --git a/pynfe/processamento/__init__.py b/pynfe/processamento/__init__.py index 7746eb8..edde458 100644 --- a/pynfe/processamento/__init__.py +++ b/pynfe/processamento/__init__.py @@ -1,6 +1,5 @@ from .serializacao import SerializacaoXML from .validacao import Validacao -#from assinatura import AssinaturaA1 -#from comunicacao import ComunicacaoSefaz +from .assinatura import AssinaturaA1 +from .comunicacao import ComunicacaoSefaz from .danfe import DANFE - diff --git a/pynfe/processamento/comunicacao.py b/pynfe/processamento/comunicacao.py index 9ddbe55..0583a66 100644 --- a/pynfe/processamento/comunicacao.py +++ b/pynfe/processamento/comunicacao.py @@ -1,17 +1,16 @@ # -*- coding: utf-8 -*- import datetime -from httplib import HTTPSConnection, HTTPResponse - +import requests from pynfe.utils import etree, StringIO, so_numeros from pynfe.utils.flags import NAMESPACE_NFE, NAMESPACE_SOAP, VERSAO_PADRAO from pynfe.utils.flags import CODIGOS_ESTADOS, VERSAO_PADRAO -from assinatura import AssinaturaA1 +from .assinatura import AssinaturaA1 class Comunicacao(object): u"""Classe abstrata responsavel por definir os metodos e logica das classes de comunicação com os webservices da NF-e.""" - _ambiente = 1 # 1 = Produção, 2 = Homologação + _ambiente = 2 # 1 = Produção, 2 = Homologação servidor = None porta = 80 certificado = None @@ -22,14 +21,14 @@ class Comunicacao(object): self.porta = porta self.certificado = certificado self.certificado_senha = certificado_senha - self._ambiente = homologacao and 2 or 1 + self._ambiente = 2 class ComunicacaoSefaz(Comunicacao): u"""Classe de comunicação que segue o padrão definido para as SEFAZ dos Estados.""" _versao = VERSAO_PADRAO _assinatura = AssinaturaA1 - + def transmitir(self, nota_fiscal): pass @@ -40,27 +39,21 @@ class ComunicacaoSefaz(Comunicacao): pass def status_servico(self): - post = '/nfeweb/services/nfestatusservico.asmx' - - # Monta XML do corpo da requisição # FIXME - raiz = etree.Element('teste') - dados = etree.tostring(raiz) - + post = self.servidor + + # Monta XML do corpo da requisição + raiz = etree.Element('consStatServ', versao='3.10', xmlns='http://www.portalfiscal.inf.br/nfe') + etree.SubElement(raiz, 'tpAmb').text = str(self._ambiente) + etree.SubElement(raiz, 'cUF').text = str(41) + etree.SubElement(raiz, 'xServ').text = 'STATUS' + dados = etree.tostring(raiz, encoding='UTF-8') # Monta XML para envio da requisição - xml = self._construir_xml_soap( - metodo='nfeRecepcao2', # FIXME - tag_metodo='nfeStatusServicoNF2', # FIXME - cabecalho=self._cabecalho_soap(), - dados=dados, - ) + xml = self._construir_xml_soap(cabecalho=self._cabecalho_soap(), dados=dados) # Chama método que efetua a requisição POST no servidor SOAP retorno = self._post(post, xml, self._post_header()) - - # Transforma o retorno em etree - #retorno = etree.parse(StringIO(retorno)) - - return bool(retorno) + return retorno + #return bool(retorno) def consultar_cadastro(self, instancia): #post = '/nfeweb/services/cadconsultacadastro.asmx' @@ -125,50 +118,48 @@ class ComunicacaoSefaz(Comunicacao): def _cabecalho_soap(self): u"""Monta o XML do cabeçalho da requisição SOAP""" - raiz = etree.Element('cabecMsg', xmlns=NAMESPACE_NFE, versao="1.02") - etree.SubElement(raiz, 'versaoDados').text = self._versao + raiz = etree.Element('nfeCabecMsg') + etree.SubElement(raiz, 'cUF').text = str(41) + etree.SubElement(raiz, 'versaoDados').text = VERSAO_PADRAO - return etree.tostring(raiz, encoding='utf-8', xml_declaration=True) + return etree.tostring(raiz, encoding='UTF-8') - def _construir_xml_soap(self, metodo, tag_metodo, cabecalho, dados): + def _construir_xml_soap(self, cabecalho, dados): u"""Mota o XML para o envio via SOAP""" - raiz = etree.Element('{%s}Envelope'%NAMESPACE_SOAP, nsmap={'soap': NAMESPACE_SOAP}) - + raiz = etree.Element('{%s}Envelope'%NAMESPACE_SOAP, nsmap={'soap': NAMESPACE_SOAP}, xmlns=self.servidor) + etree.SubElement(raiz, '{%s}Header'%NAMESPACE_SOAP).text = cabecalho body = etree.SubElement(raiz, '{%s}Body'%NAMESPACE_SOAP) - met = etree.SubElement( - body, tag_metodo, xmlns="http://www.portalfiscal.inf.br/nfe/wsdl/%s"%metodo, - ) - - etree.SubElement(met, 'nfeCabecMsg').text = cabecalho - etree.SubElement(met, 'nfeDadosMsg').text = dados + etree.SubElement(body, 'nfeDadosMsg').text = dados - return etree.tostring(raiz, encoding='utf-8', xml_declaration=True) + return etree.tostring(raiz, encoding='UTF-8', xml_declaration=True) def _post_header(self): u"""Retorna um dicionário com os atributos para o cabeçalho da requisição HTTP""" return { u'content-type': u'application/soap+xml; charset=utf-8', + #u'content-type': u'text/xml; charset=utf-8', + #u'Accept': u'text/xml; charset=utf-8', u'Accept': u'application/soap+xml; charset=utf-8', } def _post(self, post, xml, header): # Separa arquivos de certificado para chave e certificado (sozinho) - caminho_chave, caminho_cert = self.certificado.separar_arquivo(senha=self.certificado_senha) + #caminho_chave, caminho_cert = self.certificado.separar_arquivo(senha=self.certificado_senha) + caminho_chave = '/home/junior/Documentos/Certificados/key.pem' + caminho_cert = '/home/junior/Documentos/Certificados/cert.pem' # Abre a conexão HTTPS - con = HTTPSConnection(self.servidor, self.porta, key_file=caminho_chave, cert_file=caminho_cert) - - try: - #con.set_debuglevel(100) - - con.request(u'POST', post, xml, header) - - resp = con.getresponse() + cert = (caminho_cert, caminho_chave) + s = str(xml, 'utf-8').replace('<', '<').replace('>', '>').replace('\'', '"').replace('\n', '') + #headers = {'content-type': 'text/xml'} - # Tudo certo! - if resp.status == 200: - return resp.read() + try: + r = requests.post(post, s, headers=self._post_header(), cert=cert, verify=False) + print (r.content) + if r == 200: + return r.text + except Exception as e: + pass finally: - con.close() - + pass diff --git a/setup.py b/setup.py index ade21a1..4df2f26 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ from setuptools import setup, find_packages setup( name='PyNFe', - version='0.1-custom', + version='0.2', packages=find_packages(), package_data={ 'pynfe': ['data/**/*.txt'], diff --git a/texte.xml b/texte.xml index 52d47b0..df73f3a 100644 --- a/texte.xml +++ b/texte.xml @@ -8,8 +8,8 @@ 55 1 1 - 2015-07-14T00:03:20-03:00 - 2015-07-14T00:03:20-03:00 + 2015-07-14T16:50:11-03:00 + 2015-07-14T16:50:11-03:00 1 1 4118402 From 129eb27154d6656f83824c463454c2b0d31827d3 Mon Sep 17 00:00:00 2001 From: Junior Tada Date: Wed, 15 Jul 2015 04:21:53 -0300 Subject: [PATCH 2/3] =?UTF-8?q?teste=20ok=20status=20nfe=20e=20nfce=20para?= =?UTF-8?q?n=C3=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pynfe/processamento/comunicacao.py | 44 ++++++++++++++++++++++---------------- pynfe/utils/webservices_nfce.py | 2 ++ 2 files changed, 27 insertions(+), 19 deletions(-) create mode 100644 pynfe/utils/webservices_nfce.py diff --git a/pynfe/processamento/comunicacao.py b/pynfe/processamento/comunicacao.py index 0583a66..72c0039 100644 --- a/pynfe/processamento/comunicacao.py +++ b/pynfe/processamento/comunicacao.py @@ -1,9 +1,8 @@ # -*- coding: utf-8 -*- import datetime import requests -from pynfe.utils import etree, StringIO, so_numeros -from pynfe.utils.flags import NAMESPACE_NFE, NAMESPACE_SOAP, VERSAO_PADRAO -from pynfe.utils.flags import CODIGOS_ESTADOS, VERSAO_PADRAO +from pynfe.utils import etree, so_numeros +from pynfe.utils.flags import NAMESPACE_NFE, NAMESPACE_SOAP, VERSAO_PADRAO, CODIGOS_ESTADOS from .assinatura import AssinaturaA1 class Comunicacao(object): @@ -11,17 +10,15 @@ class Comunicacao(object): de comunicação com os webservices da NF-e.""" _ambiente = 2 # 1 = Produção, 2 = Homologação - servidor = None - porta = 80 + uf = None certificado = None certificado_senha = None - def __init__(self, servidor, porta, certificado, certificado_senha, homologacao=False): - self.servidor = servidor - self.porta = porta + def __init__(self, uf, certificado, certificado_senha, homologacao=False): + self.uf = uf self.certificado = certificado self.certificado_senha = certificado_senha - self._ambiente = 2 + self._ambiente = 2 if homologacao else 1 class ComunicacaoSefaz(Comunicacao): u"""Classe de comunicação que segue o padrão definido para as SEFAZ dos Estados.""" @@ -38,21 +35,30 @@ class ComunicacaoSefaz(Comunicacao): def situacao_nfe(self, nota_fiscal): pass - def status_servico(self): - post = self.servidor + def status_servico(self, tipo): + """ Verifica status do servidor da receita. """ + if self._ambiente == 1: + ambiente = 'https://' + else: + ambiente = 'https://homologacao.' + if tipo == 'nfe': + # nfe + url = ambiente + 'nfe.fazenda.pr.gov.br/nfe/NFeStatusServico3' + else: + # nfce + url = ambiente + 'nfce.fazenda.pr.gov.br/nfce/NFeStatusServico3' # Monta XML do corpo da requisição - raiz = etree.Element('consStatServ', versao='3.10', xmlns='http://www.portalfiscal.inf.br/nfe') + raiz = etree.Element('consStatServ', versao='3.10', xmlns=NAMESPACE_NFE) etree.SubElement(raiz, 'tpAmb').text = str(self._ambiente) - etree.SubElement(raiz, 'cUF').text = str(41) + etree.SubElement(raiz, 'cUF').text = CODIGOS_ESTADOS[self.uf.upper()] etree.SubElement(raiz, 'xServ').text = 'STATUS' dados = etree.tostring(raiz, encoding='UTF-8') # Monta XML para envio da requisição - xml = self._construir_xml_soap(cabecalho=self._cabecalho_soap(), dados=dados) - + xml = self._construir_xml_soap(cabecalho=self._cabecalho_soap(), dados=dados, url=url) + # Chama método que efetua a requisição POST no servidor SOAP - retorno = self._post(post, xml, self._post_header()) - return retorno + return self._post(url, xml, self._post_header()) #return bool(retorno) def consultar_cadastro(self, instancia): @@ -124,10 +130,10 @@ class ComunicacaoSefaz(Comunicacao): return etree.tostring(raiz, encoding='UTF-8') - def _construir_xml_soap(self, cabecalho, dados): + def _construir_xml_soap(self, cabecalho, dados, url): u"""Mota o XML para o envio via SOAP""" - raiz = etree.Element('{%s}Envelope'%NAMESPACE_SOAP, nsmap={'soap': NAMESPACE_SOAP}, xmlns=self.servidor) + raiz = etree.Element('{%s}Envelope'%NAMESPACE_SOAP, nsmap={'soap': NAMESPACE_SOAP}, xmlns=url) etree.SubElement(raiz, '{%s}Header'%NAMESPACE_SOAP).text = cabecalho body = etree.SubElement(raiz, '{%s}Body'%NAMESPACE_SOAP) etree.SubElement(body, 'nfeDadosMsg').text = dados diff --git a/pynfe/utils/webservices_nfce.py b/pynfe/utils/webservices_nfce.py new file mode 100644 index 0000000..793f1c8 --- /dev/null +++ b/pynfe/utils/webservices_nfce.py @@ -0,0 +1,2 @@ +# Paraná + From 103cdb923c81d8976548ce13011a5f3f1f5bef94 Mon Sep 17 00:00:00 2001 From: Junior Tada Date: Wed, 15 Jul 2015 13:52:44 -0300 Subject: [PATCH 3/3] =?UTF-8?q?webservides=20para=20Paran=C3=A1=20e=20Sao?= =?UTF-8?q?=20Paulo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pynfe/processamento/comunicacao.py | 20 +- pynfe/utils/flags.py | 2 - pynfe/utils/webservices.py | 467 +++++++++++++++++++++++++++++++++++++ pynfe/utils/webservices_nfce.py | 2 - test.py | 10 +- 5 files changed, 483 insertions(+), 18 deletions(-) create mode 100644 pynfe/utils/webservices.py delete mode 100644 pynfe/utils/webservices_nfce.py diff --git a/pynfe/processamento/comunicacao.py b/pynfe/processamento/comunicacao.py index 72c0039..efae46c 100644 --- a/pynfe/processamento/comunicacao.py +++ b/pynfe/processamento/comunicacao.py @@ -3,13 +3,14 @@ import datetime import requests from pynfe.utils import etree, so_numeros from pynfe.utils.flags import NAMESPACE_NFE, NAMESPACE_SOAP, VERSAO_PADRAO, CODIGOS_ESTADOS +from pynfe.utils.webservices import NFCE, NFE from .assinatura import AssinaturaA1 class Comunicacao(object): u"""Classe abstrata responsavel por definir os metodos e logica das classes de comunicação com os webservices da NF-e.""" - _ambiente = 2 # 1 = Produção, 2 = Homologação + _ambiente = 1 # 1 = Produção, 2 = Homologação uf = None certificado = None certificado_senha = None @@ -26,7 +27,7 @@ class ComunicacaoSefaz(Comunicacao): _versao = VERSAO_PADRAO _assinatura = AssinaturaA1 - def transmitir(self, nota_fiscal): + def autorizacao(self, nota_fiscal): pass def cancelar(self, nota_fiscal): @@ -37,16 +38,22 @@ class ComunicacaoSefaz(Comunicacao): def status_servico(self, tipo): """ Verifica status do servidor da receita. """ + """ tipo é a string com tipo de serviço que deseja consultar + Ex: nfe ou nfce + """ if self._ambiente == 1: ambiente = 'https://' else: ambiente = 'https://homologacao.' if tipo == 'nfe': - # nfe - url = ambiente + 'nfe.fazenda.pr.gov.br/nfe/NFeStatusServico3' + # nfe Ex: https://nfe.fazenda.pr.gov.br/nfe/NFeStatusServico3 + url = ambiente + NFE[self.uf.upper()]['STATUS'] + elif tipo == 'nfce': + # nfce Ex: https://homologacao.nfce.fazenda.pr.gov.br/nfce/NFeStatusServico3 + url = ambiente + NFCE[self.uf.upper()]['STATUS'] else: - # nfce - url = ambiente + 'nfce.fazenda.pr.gov.br/nfce/NFeStatusServico3' + # TODO implementar outros tipos de notas como NFS-e + pass # Monta XML do corpo da requisição raiz = etree.Element('consStatServ', versao='3.10', xmlns=NAMESPACE_NFE) @@ -59,7 +66,6 @@ class ComunicacaoSefaz(Comunicacao): # Chama método que efetua a requisição POST no servidor SOAP return self._post(url, xml, self._post_header()) - #return bool(retorno) def consultar_cadastro(self, instancia): #post = '/nfeweb/services/cadconsultacadastro.asmx' diff --git a/pynfe/utils/flags.py b/pynfe/utils/flags.py index 7a844bd..024cbf0 100644 --- a/pynfe/utils/flags.py +++ b/pynfe/utils/flags.py @@ -196,5 +196,3 @@ CODIGOS_ESTADOS = { 'GO': '52', 'DF': '53', } - - diff --git a/pynfe/utils/webservices.py b/pynfe/utils/webservices.py new file mode 100644 index 0000000..096aab6 --- /dev/null +++ b/pynfe/utils/webservices.py @@ -0,0 +1,467 @@ + +# Nfc-e +NFCE = { + 'RO': { + 'STATUS': '', + 'AUTORIZACAO': '', + 'RECIBO': '', + 'CHAVE': '', + 'INUTILIZACAO': '', + 'EVENTOS': '' + }, + 'AC': { + 'STATUS': '', + 'AUTORIZACAO': '', + 'RECIBO': '', + 'CHAVE': '', + 'INUTILIZACAO': '', + 'EVENTOS': '' + }, + 'AM': { + 'STATUS': '', + 'AUTORIZACAO': '', + 'RECIBO': '', + 'CHAVE': '', + 'INUTILIZACAO': '', + 'EVENTOS': '' + }, + 'RR': { + 'STATUS': '', + 'AUTORIZACAO': '', + 'RECIBO': '', + 'CHAVE': '', + 'INUTILIZACAO': '', + 'EVENTOS': '' + }, + 'PA': { + 'STATUS': '', + 'AUTORIZACAO': '', + 'RECIBO': '', + 'CHAVE': '', + 'INUTILIZACAO': '', + 'EVENTOS': '' + }, + 'AP': { + 'STATUS': '', + 'AUTORIZACAO': '', + 'RECIBO': '', + 'CHAVE': '', + 'INUTILIZACAO': '', + 'EVENTOS': '' + }, + 'TO': { + 'STATUS': '', + 'AUTORIZACAO': '', + 'RECIBO': '', + 'CHAVE': '', + 'INUTILIZACAO': '', + 'EVENTOS': '' + }, + 'MA': { + 'STATUS': '', + 'AUTORIZACAO': '', + 'RECIBO': '', + 'CHAVE': '', + 'INUTILIZACAO': '', + 'EVENTOS': '' + }, + 'PI': { + 'STATUS': '', + 'AUTORIZACAO': '', + 'RECIBO': '', + 'CHAVE': '', + 'INUTILIZACAO': '', + 'EVENTOS': '' + }, + 'CE': { + 'STATUS': '', + 'AUTORIZACAO': '', + 'RECIBO': '', + 'CHAVE': '', + 'INUTILIZACAO': '', + 'EVENTOS': '' + }, + 'RN': { + 'STATUS': '', + 'AUTORIZACAO': '', + 'RECIBO': '', + 'CHAVE': '', + 'INUTILIZACAO': '', + 'EVENTOS': '' + }, + 'PB': { + 'STATUS': '', + 'AUTORIZACAO': '', + 'RECIBO': '', + 'CHAVE': '', + 'INUTILIZACAO': '', + 'EVENTOS': '' + }, + 'PE': { + 'STATUS': '', + 'AUTORIZACAO': '', + 'RECIBO': '', + 'CHAVE': '', + 'INUTILIZACAO': '', + 'EVENTOS': '' + }, + 'AL': { + 'STATUS': '', + 'AUTORIZACAO': '', + 'RECIBO': '', + 'CHAVE': '', + 'INUTILIZACAO': '', + 'EVENTOS': '' + }, + 'SE': { + 'STATUS': '', + 'AUTORIZACAO': '', + 'RECIBO': '', + 'CHAVE': '', + 'INUTILIZACAO': '', + 'EVENTOS': '' + }, + 'BA': { + 'STATUS': '', + 'AUTORIZACAO': '', + 'RECIBO': '', + 'CHAVE': '', + 'INUTILIZACAO': '', + 'EVENTOS': '' + }, + 'MG': { + 'STATUS': '', + 'AUTORIZACAO': '', + 'RECIBO': '', + 'CHAVE': '', + 'INUTILIZACAO': '', + 'EVENTOS': '' + }, + 'ES': { + 'STATUS': '', + 'AUTORIZACAO': '', + 'RECIBO': '', + 'CHAVE': '', + 'INUTILIZACAO': '', + 'EVENTOS': '' + }, + 'RJ': { + 'STATUS': '', + 'AUTORIZACAO': '', + 'RECIBO': '', + 'CHAVE': '', + 'INUTILIZACAO': '', + 'EVENTOS': '' + }, + 'SP': { + 'STATUS': 'nfce.fazenda.sp.gov.br/ws/nfestatusservico2.asmx', + 'AUTORIZACAO': 'nfce.fazenda.sp.gov.br/ws/nfeautorizacao.asmx', + 'RECIBO': 'nfce.fazenda.sp.gov.br/ws/nferetautorizacao.asmx', + 'CHAVE': 'nfce.fazenda.sp.gov.br/ws/nfeconsulta2.asmx', + 'INUTILIZACAO': 'nfce.fazenda.sp.gov.br/ws/nfeinutilizacao2.asmx', + 'EVENTOS': 'nfce.fazenda.sp.gov.br/ws/recepcaoevento.asmx' + }, + 'PR': { + 'STATUS': 'nfce.fazenda.pr.gov.br/nfce/NFeStatusServico3', + 'AUTORIZACAO': 'nfce.fazenda.pr.gov.br/nfce/NFeAutorizacao3', + 'RECIBO': 'nfce.fazenda.pr.gov.br/nfce/NFeRetAutorizacao3', + 'CHAVE': 'nfce.fazenda.pr.gov.br/nfce/NFeConsulta3', + 'INUTILIZACAO': 'nfce.fazenda.pr.gov.br/nfce/NFeInutilizacao3', + 'EVENTOS': 'nfce.fazenda.pr.gov.br/nfce/NFeRecepcaoEvento' + }, + 'SC': { + 'STATUS': '', + 'AUTORIZACAO': '', + 'RECIBO': '', + 'CHAVE': '', + 'INUTILIZACAO': '', + 'EVENTOS': '' + }, + 'RS': { + 'STATUS': '', + 'AUTORIZACAO': '', + 'RECIBO': '', + 'CHAVE': '', + 'INUTILIZACAO': '', + 'EVENTOS': '' + }, + 'MS': { + 'STATUS': '', + 'AUTORIZACAO': '', + 'RECIBO': '', + 'CHAVE': '', + 'INUTILIZACAO': '', + 'EVENTOS': '' + }, + 'MT': { + 'STATUS': '', + 'AUTORIZACAO': '', + 'RECIBO': '', + 'CHAVE': '', + 'INUTILIZACAO': '', + 'EVENTOS': '' + }, + 'GO': { + 'STATUS': '', + 'AUTORIZACAO': '', + 'RECIBO': '', + 'CHAVE': '', + 'INUTILIZACAO': '', + 'EVENTOS': '' + }, + 'DF': { + 'STATUS': '', + 'AUTORIZACAO': '', + 'RECIBO': '', + 'CHAVE': '', + 'INUTILIZACAO': '', + 'EVENTOS': '' + }, +} + +# Nfe +NFE = { + 'RO': { + 'STATUS': '', + 'AUTORIZACAO': '', + 'RECIBO': '', + 'CHAVE': '', + 'INUTILIZACAO': '', + 'EVENTOS': '', + 'CADASTRO': '' + }, + 'AC': { + 'STATUS': '', + 'AUTORIZACAO': '', + 'RECIBO': '', + 'CHAVE': '', + 'INUTILIZACAO': '', + 'EVENTOS': '', + 'CADASTRO': '' + }, + 'AM': { + 'STATUS': '', + 'AUTORIZACAO': '', + 'RECIBO': '', + 'CHAVE': '', + 'INUTILIZACAO': '', + 'EVENTOS': '', + 'CADASTRO': '' + }, + 'RR': { + 'STATUS': '', + 'AUTORIZACAO': '', + 'RECIBO': '', + 'CHAVE': '', + 'INUTILIZACAO': '', + 'EVENTOS': '', + 'CADASTRO': '' + }, + 'PA': { + 'STATUS': '', + 'AUTORIZACAO': '', + 'RECIBO': '', + 'CHAVE': '', + 'INUTILIZACAO': '', + 'EVENTOS': '', + 'CADASTRO': '' + }, + 'AP': { + 'STATUS': '', + 'AUTORIZACAO': '', + 'RECIBO': '', + 'CHAVE': '', + 'INUTILIZACAO': '', + 'EVENTOS': '', + 'CADASTRO': '' + }, + 'TO': { + 'STATUS': '', + 'AUTORIZACAO': '', + 'RECIBO': '', + 'CHAVE': '', + 'INUTILIZACAO': '', + 'EVENTOS': '', + 'CADASTRO': '' + }, + 'MA': { + 'STATUS': '', + 'AUTORIZACAO': '', + 'RECIBO': '', + 'CHAVE': '', + 'INUTILIZACAO': '', + 'EVENTOS': '', + 'CADASTRO': '' + }, + 'PI': { + 'STATUS': '', + 'AUTORIZACAO': '', + 'RECIBO': '', + 'CHAVE': '', + 'INUTILIZACAO': '', + 'EVENTOS': '', + 'CADASTRO': '' + }, + 'CE': { + 'STATUS': '', + 'AUTORIZACAO': '', + 'RECIBO': '', + 'CHAVE': '', + 'INUTILIZACAO': '', + 'EVENTOS': '', + 'CADASTRO': '' + }, + 'RN': { + 'STATUS': '', + 'AUTORIZACAO': '', + 'RECIBO': '', + 'CHAVE': '', + 'INUTILIZACAO': '', + 'EVENTOS': '', + 'CADASTRO': '' + }, + 'PB': { + 'STATUS': '', + 'AUTORIZACAO': '', + 'RECIBO': '', + 'CHAVE': '', + 'INUTILIZACAO': '', + 'EVENTOS': '', + 'CADASTRO': '' + }, + 'PE': { + 'STATUS': '', + 'AUTORIZACAO': '', + 'RECIBO': '', + 'CHAVE': '', + 'INUTILIZACAO': '', + 'EVENTOS': '', + 'CADASTRO': '' + }, + 'AL': { + 'STATUS': '', + 'AUTORIZACAO': '', + 'RECIBO': '', + 'CHAVE': '', + 'INUTILIZACAO': '', + 'EVENTOS': '', + 'CADASTRO': '' + }, + 'SE': { + 'STATUS': '', + 'AUTORIZACAO': '', + 'RECIBO': '', + 'CHAVE': '', + 'INUTILIZACAO': '', + 'EVENTOS': '', + 'CADASTRO': '' + }, + 'BA': { + 'STATUS': '', + 'AUTORIZACAO': '', + 'RECIBO': '', + 'CHAVE': '', + 'INUTILIZACAO': '', + 'EVENTOS': '', + 'CADASTRO': '' + }, + 'MG': { + 'STATUS': '', + 'AUTORIZACAO': '', + 'RECIBO': '', + 'CHAVE': '', + 'INUTILIZACAO': '', + 'EVENTOS': '', + 'CADASTRO': '' + }, + 'ES': { + 'STATUS': '', + 'AUTORIZACAO': '', + 'RECIBO': '', + 'CHAVE': '', + 'INUTILIZACAO': '', + 'EVENTOS': '', + 'CADASTRO': '' + }, + 'RJ': { + 'STATUS': '', + 'AUTORIZACAO': '', + 'RECIBO': '', + 'CHAVE': '', + 'INUTILIZACAO': '', + 'EVENTOS': '', + 'CADASTRO': '' + }, + 'SP': { + 'STATUS': 'nfe.fazenda.sp.gov.br/ws/nfestatusservico2.asmx', + 'AUTORIZACAO': 'nfe.fazenda.sp.gov.br/ws/nfeautorizacao.asmx', + 'RECIBO': 'nfe.fazenda.sp.gov.br/ws/nferetautorizacao.asmx', + 'CHAVE': 'nfe.fazenda.sp.gov.br/ws/nfeconsulta2.asmx', + 'INUTILIZACAO': 'nfe.fazenda.sp.gov.br/ws/nfeinutilizacao2.asmx', + 'EVENTOS': 'nfe.fazenda.sp.gov.br/ws/nfestatusservico2.asmx', + 'CADASTRO': 'nfe.fazenda.sp.gov.br/ws/cadconsultacadastro2.asmx' + }, + 'PR': { + 'STATUS': 'nfe.fazenda.pr.gov.br/nfe/NFeStatusServico3', # CONSULTA STATUS DO SERVIÇO + 'AUTORIZACAO': 'nfe.fazenda.pr.gov.br/nfe/NFeAutorizacao3', # AUTORIZACAO + 'RECIBO': 'nfe.fazenda.pr.gov.br/nfe/NFeRetAutorizacao3', # CONSULTA RECIBO + 'CHAVE': 'nfe.fazenda.pr.gov.br/nfe/NFeConsulta3', # CONSULTA CHAVE DE ACESSO + 'INUTILIZACAO': 'nfe.fazenda.pr.gov.br/nfe/NFeInutilizacao3', # INUTILIZAÇAO + 'EVENTOS': 'nfe.fazenda.pr.gov.br/nfe/NFeRecepcaoEvento', # REGISTRO DE EVENTOS + 'CADASTRO': 'nfe.fazenda.pr.gov.br/nfe/CadConsultaCadastro2' # CONSULTA CADASTRO + }, + 'SC': { + 'STATUS': '', + 'AUTORIZACAO': '', + 'RECIBO': '', + 'CHAVE': '', + 'INUTILIZACAO': '', + 'EVENTOS': '', + 'CADASTRO': '' + }, + 'RS': { + 'STATUS': '', + 'AUTORIZACAO': '', + 'RECIBO': '', + 'CHAVE': '', + 'INUTILIZACAO': '', + 'EVENTOS': '', + 'CADASTRO': '' + }, + 'MS': { + 'STATUS': '', + 'AUTORIZACAO': '', + 'RECIBO': '', + 'CHAVE': '', + 'INUTILIZACAO': '', + 'EVENTOS': '', + 'CADASTRO': '' + }, + 'MT': { + 'STATUS': '', + 'AUTORIZACAO': '', + 'RECIBO': '', + 'CHAVE': '', + 'INUTILIZACAO': '', + 'EVENTOS': '', + 'CADASTRO': '' + }, + 'GO': { + 'STATUS': '', + 'AUTORIZACAO': '', + 'RECIBO': '', + 'CHAVE': '', + 'INUTILIZACAO': '', + 'EVENTOS': '', + 'CADASTRO': '' + }, + 'DF': { + 'STATUS': '', + 'AUTORIZACAO': '', + 'RECIBO': '', + 'CHAVE': '', + 'INUTILIZACAO': '', + 'EVENTOS': '', + 'CADASTRO': '' + }, +} \ No newline at end of file diff --git a/pynfe/utils/webservices_nfce.py b/pynfe/utils/webservices_nfce.py deleted file mode 100644 index 793f1c8..0000000 --- a/pynfe/utils/webservices_nfce.py +++ /dev/null @@ -1,2 +0,0 @@ -# Paraná - diff --git a/test.py b/test.py index 00ff878..da8aca6 100644 --- a/test.py +++ b/test.py @@ -100,17 +100,13 @@ nota_fiscal.adicionar_produto_servico(codigo='000328', # id do produto (000328 e cofins_aliquota_percentual=Decimal('3.00'), cofins_valor=Decimal('3.51')) -#_fonte_dados.adicionar_objeto(nota_fiscal) - serializador = SerializacaoXML(_fonte_dados, homologacao=True) xml = serializador.exportar(retorna_string=True).decode('utf-8') -certificado = "JC.pfx" -senha = '12345328' +certificado = "certificado_A1.pfx" +senha = 'sua_senha' # assinatura a1 = AssinaturaA1(certificado, senha) xml = a1.assinar_nfe(xml) # escreve with open('teste.xml', 'wb') as arquivo: - arquivo.write(xml) - -#print serializador._serializar_nota_fiscal(nota_fiscal) + arquivo.write(xml) \ No newline at end of file