From 371fc47a25df37f23e1bfe9fabbbdd478e0c233d Mon Sep 17 00:00:00 2001 From: Patrick Acioli Date: Tue, 18 Jun 2019 20:51:09 -0300 Subject: [PATCH 01/14] Add specific version of PyXB --- requirements-nfse.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-nfse.txt b/requirements-nfse.txt index a203ffa..582da17 100644 --- a/requirements-nfse.txt +++ b/requirements-nfse.txt @@ -1,3 +1,3 @@ # Opcional para NFS-e suds-jurko -pyxb +pyxb=1.2.4 From d37c46ff30205c10b16b5f29eefcbdf5db15e21b Mon Sep 17 00:00:00 2001 From: juniortada Date: Mon, 1 Jul 2019 21:18:04 -0300 Subject: [PATCH 02/14] [new] add NFC-e MG #69 --- pynfe/processamento/serializacao.py | 4 ++-- pynfe/utils/webservices.py | 18 +++++++++++------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/pynfe/processamento/serializacao.py b/pynfe/processamento/serializacao.py index c87074a..6cbec9b 100644 --- a/pynfe/processamento/serializacao.py +++ b/pynfe/processamento/serializacao.py @@ -757,10 +757,10 @@ class SerializacaoQrcode(object): elif uf.upper() == 'SP': if tpamb == '1': qrcode = NFCE[uf.upper()]['HTTPS'] + 'www.' + NFCE[uf.upper()]['QR'] + url - url_chave = NFCE[uf.upper()]['HTTPS'] + 'www.' + NFCE[uf.upper()]['URL'] + url + url_chave = NFCE[uf.upper()]['HTTPS'] + 'www.' + NFCE[uf.upper()]['URL'] else: qrcode = NFCE[uf.upper()]['HTTPS'] + 'www.homologacao.' + NFCE[uf.upper()]['QR'] + url - url_chave = NFCE[uf.upper()]['HTTPS'] + 'www.homologacao.' + NFCE[uf.upper()]['URL'] + url + url_chave = NFCE[uf.upper()]['HTTPS'] + 'www.homologacao.' + NFCE[uf.upper()]['URL'] # BA tem comportamento distindo para qrcode e url elif uf.upper() == 'BA': if tpamb == '1': diff --git a/pynfe/utils/webservices.py b/pynfe/utils/webservices.py index d3c58af..51dc74b 100644 --- a/pynfe/utils/webservices.py +++ b/pynfe/utils/webservices.py @@ -157,13 +157,17 @@ NFCE = { 'URL': 'http://hinternet.sefaz.ba.gov.br/nfce/consulta' }, 'MG': { - 'STATUS': '', - 'AUTORIZACAO': '', - 'RECIBO': '', - 'CHAVE': '', - 'INUTILIZACAO': '', - 'EVENTOS': '', - 'QR': '' + 'STATUS': 'fazenda.mg.gov.br/nfce/services/NFeStatusServico4', + 'AUTORIZACAO': 'fazenda.mg.gov.br/nfce/services/NFeAutorizacao4', + 'RECIBO': 'fazenda.mg.gov.br/nfce/services/NFeRetAutorizacao4', + 'CHAVE': 'fazenda.mg.gov.br/nfce/services/NFeConsultaProtocolo4', + 'INUTILIZACAO': 'fazenda.mg.gov.br/nfce/services/NFeInutilizacao4', + 'EVENTOS': 'fazenda.mg.gov.br/nfce/services/NFeRecepcaoEvento4', + 'CADASTRO': 'fazenda.mg.gov.br/nfce/services/CadConsultaCadastro4', + 'QR': 'fazenda.mg.gov.br/portalnfce/sistema/qrcode.xhtml?', + 'HTTPS': 'https://nfce.', + 'HOMOLOGACAO': 'https://hnfce.', + 'URL': 'fazenda.mg.gov.br/portalnfce' }, 'ES': { 'STATUS': '', From 2eb45107fe954d4596e335bc0e952afa9a52bea8 Mon Sep 17 00:00:00 2001 From: juniortada Date: Mon, 9 Sep 2019 15:55:15 -0300 Subject: [PATCH 03/14] update readme and setup --- README.md | 4 +++- setup.py | 10 +++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index eb45520..b8ee260 100644 --- a/README.md +++ b/README.md @@ -91,7 +91,9 @@ Documentação - https://github.com/leotada/PyNFe/wiki - http://pynfe.readthedocs.org/pt/latest/ -backlog: + +Backlog +------- - renomeado metodo serializar_evento (_serializar_evento) - removido metoco con.cancelar (utilizar con.evento) - add evento carta de correção (con.evento) diff --git a/setup.py b/setup.py index f042f17..13d22d3 100644 --- a/setup.py +++ b/setup.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -from setuptools import setup, find_packages +import setuptools try: # for pip >= 10 from pip._internal.req import parse_requirements as parse except ImportError: # for pip <= 9.0.3 @@ -7,13 +7,17 @@ except ImportError: # for pip <= 9.0.3 requirements = lambda f: [str(i.req) for i in parse(f, session=False)] -setup( +setuptools.setup( name='PyNFe', version='0.4', - packages=find_packages(), + author='TadaSoftware', + author_email='tadasoftware@gmail.com', + url='https://github.com/TadaSoftware', + packages=setuptools.find_packages(), package_data={ 'pynfe': ['data/**/*.txt'], }, install_requires=requirements('requirements.txt'), zip_safe=False, + python_requires='>=3.6', ) From e9f20a6b1c2711ff5d3d1d9fc14fe65c0df8c6b3 Mon Sep 17 00:00:00 2001 From: juniortada Date: Wed, 11 Sep 2019 19:30:16 -0300 Subject: [PATCH 04/14] [fix] atualizado SVAN apenas MA e SVRS NFC-e MA --- pynfe/processamento/comunicacao.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/pynfe/processamento/comunicacao.py b/pynfe/processamento/comunicacao.py index 5b915ea..1232ce3 100644 --- a/pynfe/processamento/comunicacao.py +++ b/pynfe/processamento/comunicacao.py @@ -358,8 +358,7 @@ class ComunicacaoSefaz(Comunicacao): raise Exception('Modelo não encontrado! Defina modelo="nfe" ou "nfce"') # Estados que utilizam outros ambientes else: - lista_svrs = ['AC', 'RJ', 'RN', 'PB', 'SC', 'SE', 'PI', 'DF', 'ES'] - lista_svan = ['MA','PA'] + lista_svrs = ['AC', 'RJ', 'RN', 'PB', 'SC', 'SE', 'PI', 'DF', 'ES', 'PA'] if self.uf.upper() in lista_svrs: if self._ambiente == 1: ambiente = 'HTTPS' @@ -373,7 +372,9 @@ class ComunicacaoSefaz(Comunicacao): self.url = NFCE['SVRS'][ambiente] + NFCE['SVRS'][consulta] else: raise Exception('Modelo não encontrado! Defina modelo="nfe" ou "nfce"') - elif self.uf.upper() in lista_svan: + # unico UF que utiliza SVAN ainda para NF-e + # SVRS para NFC-e + elif self.uf.upper() == 'MA': if self._ambiente == 1: ambiente = 'HTTPS' else: @@ -383,9 +384,11 @@ class ComunicacaoSefaz(Comunicacao): self.url = NFE['SVAN'][ambiente] + NFE['SVAN'][consulta] elif modelo == 'nfce': # nfce Ex: https://homologacao.nfce.fazenda.pr.gov.br/nfce/NFeStatusServico3 - self.url = NFCE['SVAN'][ambiente] + NFCE['SVAN'][consulta] + self.url = NFCE['SVRS'][ambiente] + NFCE['SVRS'][consulta] else: raise Exception('Modelo não encontrado! Defina modelo="nfe" ou "nfce"') + else: + raise Exception(f"Url não encontrada para {modelo} e {consulta} {self.uf.upper()}") return self.url def _construir_xml_soap(self, metodo, dados, cabecalho=False): From c1abb35bb7188c1f07c2e260d1e5b35212eb6ebf Mon Sep 17 00:00:00 2001 From: Junior Tada Date: Tue, 24 Sep 2019 17:10:42 -0300 Subject: [PATCH 05/14] =?UTF-8?q?[new]=20add=20cBenef=20(c=C3=B3digo=20de?= =?UTF-8?q?=20benef=C3=ADcio=20fiscal=20na=20UF)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pynfe/entidades/produto.py | 2 ++ pynfe/processamento/serializacao.py | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/pynfe/entidades/produto.py b/pynfe/entidades/produto.py index 21e3cfb..6d06e96 100644 --- a/pynfe/entidades/produto.py +++ b/pynfe/entidades/produto.py @@ -34,6 +34,8 @@ class Produto(Entidade): # Tabela https://www.confaz.fazenda.gov.br/anexo-i.pdf cest = str() + cbenef = str() + # - Unid. Com. unidade_comercial = str() diff --git a/pynfe/processamento/serializacao.py b/pynfe/processamento/serializacao.py index 6cbec9b..559a691 100644 --- a/pynfe/processamento/serializacao.py +++ b/pynfe/processamento/serializacao.py @@ -222,7 +222,10 @@ class SerializacaoXML(Serializacao): etree.SubElement(prod, 'NCM').text = produto_servico.ncm # Codificação opcional que detalha alguns NCM. Formato: duas letras maiúsculas e 4 algarismos. # Se a mercadoria se enquadrar em mais de uma codificação, informar até 8 codificações principais. - #etree.SubElement(prod, 'NVE').text = '' + # etree.SubElement(prod, 'NVE').text = '' + # etree.SubElement(prod, 'CEST').text = produto_service.cest + if produto_servico.cbenef: + etree.SubElement(prod, 'cBenef').text = produto_servico.cbenef etree.SubElement(prod, 'CFOP').text = produto_servico.cfop etree.SubElement(prod, 'uCom').text = produto_servico.unidade_comercial etree.SubElement(prod, 'qCom').text = str(produto_servico.quantidade_comercial or 0) From 8740ca8323a733e1e34351523197f97507d01ad6 Mon Sep 17 00:00:00 2001 From: Junior Tada Date: Wed, 23 Oct 2019 15:01:00 -0300 Subject: [PATCH 06/14] [fix] corrige url consulta cadastro SVRS --- pynfe/utils/webservices.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pynfe/utils/webservices.py b/pynfe/utils/webservices.py index 51dc74b..847ba3f 100644 --- a/pynfe/utils/webservices.py +++ b/pynfe/utils/webservices.py @@ -446,7 +446,7 @@ NFE = { 'CHAVE': 'svrs.rs.gov.br/ws/NfeConsulta/NfeConsulta4.asmx', 'INUTILIZACAO': 'svrs.rs.gov.br/ws/nfeinutilizacao/nfeinutilizacao4.asmx', 'EVENTOS': 'svrs.rs.gov.br/ws/recepcaoevento/recepcaoevento4.asmx', - 'CADASTRO': 'https://cad.svrs.rs.gov.br/ws/cadconsultacadastro/cadconsultacadastro2.asmx', + 'CADASTRO': 'https://cad.svrs.rs.gov.br/ws/cadconsultacadastro/cadconsultacadastro4.asmx', 'HTTPS': 'https://nfe.', 'HOMOLOGACAO': 'https://nfe-homologacao.' }, From 8c9273a603419829c0b9a5ac4d13c2c7030c4095 Mon Sep 17 00:00:00 2001 From: juniortada Date: Thu, 24 Oct 2019 14:00:55 -0300 Subject: [PATCH 07/14] [fix] corrigido url consulta cadastro PE --- pynfe/utils/webservices.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pynfe/utils/webservices.py b/pynfe/utils/webservices.py index 847ba3f..6eb373d 100644 --- a/pynfe/utils/webservices.py +++ b/pynfe/utils/webservices.py @@ -333,7 +333,7 @@ NFE = { 'CHAVE': 'sefaz.pe.gov.br/nfe-service/services/NFeConsultaProtocolo4', 'INUTILIZACAO': 'sefaz.pe.gov.br/nfe-service/services/NFeInutilizacao4', 'EVENTOS': 'sefaz.pe.gov.br/nfe-service/services/NFeRecepcaoEvento4', - # 'CADASTRO': 'sefaz.pe.gov.br/nfe-service/services/CadConsultaCadastro2', + 'CADASTRO': 'sefaz.pe.gov.br/nfe-service/services/CadConsultaCadastro4?wsdl', 'HTTPS': 'https://nfe.', 'HOMOLOGACAO': 'https://nfehomolog.' }, From ed8335bb76874de6e23f42e152c18a012f29e348 Mon Sep 17 00:00:00 2001 From: juniortada Date: Thu, 24 Oct 2019 14:07:33 -0300 Subject: [PATCH 08/14] [fix] corrigido url consulta cadastro CE --- pynfe/utils/webservices.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pynfe/utils/webservices.py b/pynfe/utils/webservices.py index 6eb373d..49c6029 100644 --- a/pynfe/utils/webservices.py +++ b/pynfe/utils/webservices.py @@ -321,7 +321,7 @@ NFE = { 'CHAVE': 'sefaz.ce.gov.br/nfe4/services/NFeConsultaProtocolo4?WSDL', 'INUTILIZACAO': 'sefaz.ce.gov.br/nfe4/services/NFeInutilizacao4?WSDL', 'EVENTOS': 'sefaz.ce.gov.br/nfe4/services/NFeRecepcaoEvento4?WSDL', - 'CADASTRO': 'nfe.sefaz.ce.gov.br/nfe4/services/CadConsultaCadastro4?wsdl', + 'CADASTRO': 'sefaz.ce.gov.br/nfe4/services/CadConsultaCadastro4?wsdl', 'DOWNLOAD': 'sefaz.ce.gov.br/nfe2/services/NfeDownloadNF?wsdl', 'HTTPS': 'https://nfe.', 'HOMOLOGACAO': 'https://nfeh.' From 420e8f72b2e2682cb997dd69331bf235b907e35e Mon Sep 17 00:00:00 2001 From: juniortada Date: Thu, 24 Oct 2019 14:21:08 -0300 Subject: [PATCH 09/14] [fix] atualizado lista de SVRS --- pynfe/processamento/comunicacao.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pynfe/processamento/comunicacao.py b/pynfe/processamento/comunicacao.py index 1232ce3..2a9bd41 100644 --- a/pynfe/processamento/comunicacao.py +++ b/pynfe/processamento/comunicacao.py @@ -200,7 +200,7 @@ class ComunicacaoSefaz(Comunicacao): :return: """ # UF que utilizam a SVRS - Sefaz Virtual do RS: Para serviço de Consulta Cadastro: AC, RN, PB, SC - lista_svrs = ['AC', 'RJ', 'RN', 'PB', 'SC', 'PI'] + lista_svrs = ['AC', 'RN', 'PB', 'SC'] # RS implementa um método diferente na consulta de cadastro if self.uf.upper() == 'RS': @@ -358,7 +358,7 @@ class ComunicacaoSefaz(Comunicacao): raise Exception('Modelo não encontrado! Defina modelo="nfe" ou "nfce"') # Estados que utilizam outros ambientes else: - lista_svrs = ['AC', 'RJ', 'RN', 'PB', 'SC', 'SE', 'PI', 'DF', 'ES', 'PA'] + lista_svrs = ['AC', 'AL', 'AP', 'DF', 'ES', 'PB', 'PI', 'RJ', 'RN', 'RO', 'RR', 'SC', 'SE', 'TO'] if self.uf.upper() in lista_svrs: if self._ambiente == 1: ambiente = 'HTTPS' From a81d64d2816404c2de501b331ea1f646a89f2cac Mon Sep 17 00:00:00 2001 From: Leonardo Gregianin Date: Sun, 16 Feb 2020 22:44:52 +0000 Subject: [PATCH 10/14] =?UTF-8?q?Corre=C3=A7=C3=A3o=20para=20emiss=C3=A3o?= =?UTF-8?q?=20de=20NFe=20com=20emitente=20CPF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pynfe/entidades/notafiscal.py | 4 ++-- pynfe/processamento/serializacao.py | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/pynfe/entidades/notafiscal.py b/pynfe/entidades/notafiscal.py index ed001bf..82ad525 100644 --- a/pynfe/entidades/notafiscal.py +++ b/pynfe/entidades/notafiscal.py @@ -468,7 +468,7 @@ class NotaFiscal(Entidade): 'uf': CODIGOS_ESTADOS[self.uf], 'ano': self.data_emissao.strftime('%y'), 'mes': self.data_emissao.strftime('%m'), - 'cnpj': so_numeros(self.emitente.cnpj), + 'cnpj': so_numeros(self.emitente.cnpj).zfill(14), 'mod': self.modelo, 'serie': str(self.serie).zfill(3), 'nNF': str(self.numero_nf).zfill(9), @@ -479,7 +479,7 @@ class NotaFiscal(Entidade): 'uf': CODIGOS_ESTADOS[self.uf], 'ano': self.data_emissao.strftime('%y'), 'mes': self.data_emissao.strftime('%m'), - 'cnpj': so_numeros(self.emitente.cnpj), + 'cnpj': so_numeros(self.emitente.cnpj).zfill(14), 'mod': self.modelo, 'serie': str(self.serie).zfill(3), 'nNF': str(self.numero_nf).zfill(9), diff --git a/pynfe/processamento/serializacao.py b/pynfe/processamento/serializacao.py index 559a691..34fab45 100644 --- a/pynfe/processamento/serializacao.py +++ b/pynfe/processamento/serializacao.py @@ -90,7 +90,10 @@ class SerializacaoXML(Serializacao): raiz = etree.Element(tag_raiz) # Dados do emitente - etree.SubElement(raiz, 'CNPJ').text = so_numeros(emitente.cnpj) + if len(so_numeros(emitente.cnpj)) == 11: + etree.SubElement(raiz, 'CPF').text = so_numeros(emitente.cnpj) + else: + etree.SubElement(raiz, 'CNPJ').text = so_numeros(emitente.cnpj) etree.SubElement(raiz, 'xNome').text = emitente.razao_social etree.SubElement(raiz, 'xFant').text = emitente.nome_fantasia # Endereço From 91535998c4437ba9ce5a343ffcd0b5a6f9f71103 Mon Sep 17 00:00:00 2001 From: Leonardo Date: Mon, 17 Feb 2020 16:22:23 -0300 Subject: [PATCH 11/14] =?UTF-8?q?Remove=20informa=C3=A7=C3=A3o=20antiga=20?= =?UTF-8?q?do=20readme?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 7 ------- 1 file changed, 7 deletions(-) diff --git a/README.md b/README.md index b8ee260..bacf3cf 100644 --- a/README.md +++ b/README.md @@ -90,10 +90,3 @@ Documentação ----------- - https://github.com/leotada/PyNFe/wiki - http://pynfe.readthedocs.org/pt/latest/ - - -Backlog -------- -- renomeado metodo serializar_evento (_serializar_evento) -- removido metoco con.cancelar (utilizar con.evento) -- add evento carta de correção (con.evento) From 2bb7ebddfbbf8d147fbf91fd0314f5316fc4f7fd Mon Sep 17 00:00:00 2001 From: leogregianin Date: Tue, 18 Feb 2020 07:48:15 -0400 Subject: [PATCH 12/14] =?UTF-8?q?Implementa=C3=A7=C3=A3o=20do=20CST=2051?= =?UTF-8?q?=20para=20NFes=20do=20regime=20normal?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pynfe/processamento/serializacao.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pynfe/processamento/serializacao.py b/pynfe/processamento/serializacao.py index 34fab45..e32b1ab 100644 --- a/pynfe/processamento/serializacao.py +++ b/pynfe/processamento/serializacao.py @@ -293,6 +293,11 @@ class SerializacaoXML(Serializacao): icms_item = etree.SubElement(icms, 'ICMSSN'+produto_servico.icms_modalidade) etree.SubElement(icms_item, 'orig').text = str(produto_servico.icms_origem) etree.SubElement(icms_item, 'CSOSN').text = produto_servico.icms_csosn + elif produto_servico.icms_modalidade == '51': + icms_item = etree.SubElement(icms, 'ICMS'+produto_servico.icms_modalidade) + etree.SubElement(icms_item, 'orig').text = str(produto_servico.icms_origem) + etree.SubElement(icms_item, 'CST').text = '51' + etree.SubElement(icms_item, 'modBC').text = str(produto_servico.icms_modalidade_determinacao_bc) else: ### OUTROS TIPOS DE ICMS (00,10,20) icms_item = etree.SubElement(icms, 'ICMS'+produto_servico.icms_modalidade) From 7841f0cc3e047e1f6790aa281f9d8524f8f1ad13 Mon Sep 17 00:00:00 2001 From: leogregianin Date: Tue, 18 Feb 2020 07:49:22 -0400 Subject: [PATCH 13/14] =?UTF-8?q?Implementa=C3=A7=C3=A3o=20do=20grupo=20de?= =?UTF-8?q?=20informa=C3=A7=C3=B5es=20de=20IPI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pynfe/processamento/serializacao.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/pynfe/processamento/serializacao.py b/pynfe/processamento/serializacao.py index e32b1ab..0b0c0c8 100644 --- a/pynfe/processamento/serializacao.py +++ b/pynfe/processamento/serializacao.py @@ -340,12 +340,18 @@ class SerializacaoXML(Serializacao): else: raise NotImplementedError # ipi - # ipi = etree.SubElement(imposto, 'IPI') - # etree.SubElement(ipi, 'clEnq') = produto_servico.ipi_classe_enquadramento # Preenchimento conforme Atos Normativos editados pela Receita Federal (Observação 2) - # ipint = etree.SubElement(ipi, 'IPINT') - # # 01=Entrada tributada com alíquota zero 02=Entrada isenta 03=Entrada não-tributada 04=Entrada imune 05=Entrada com suspensão - # # 51=Saída tributada com alíquota zero 52=Saída isenta 53=Saída não-tributada 54=Saída imune 55=Saída com suspensão - # etree.SubElement(ipint, 'CST') = produto_servico.ipi_codigo_enquadramento + ipint_lista = ('01','02','03','04','05','51','52','53','54','55') + if produto_servico.ipi_codigo_enquadramento in ipint_lista: + ipi = etree.SubElement(imposto, 'IPI') + # Preenchimento conforme Atos Normativos editados pela Receita Federal (Observação 2) + etree.SubElement(ipi, 'cEnq').text = produto_servico.ipi_classe_enquadramento + if produto_servico.ipi_classe_enquadramento == '': + etree.SubElement(ipi, 'cEnq').text = '999' + + ipint = etree.SubElement(ipi, 'IPINT') + # 01=Entrada tributada com alíquota zero 02=Entrada isenta 03=Entrada não-tributada 04=Entrada imune 05=Entrada com suspensão + # 51=Saída tributada com alíquota zero 52=Saída isenta 53=Saída não-tributada 54=Saída imune 55=Saída com suspensão + etree.SubElement(ipint, 'CST').text = produto_servico.ipi_codigo_enquadramento # apenas nfe if modelo == 55: From 02444339ab2ef1063eee90eca69e1b36afe9021a Mon Sep 17 00:00:00 2001 From: leogregianin Date: Thu, 20 Feb 2020 07:32:20 -0400 Subject: [PATCH 14/14] =?UTF-8?q?[fix]=20Corre=C3=A7=C3=A3o=20do=20envio?= =?UTF-8?q?=20de=20Eventos=20com=20emitentes=20CPF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pynfe/processamento/serializacao.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pynfe/processamento/serializacao.py b/pynfe/processamento/serializacao.py index 0b0c0c8..c571654 100644 --- a/pynfe/processamento/serializacao.py +++ b/pynfe/processamento/serializacao.py @@ -687,8 +687,10 @@ class SerializacaoXML(Serializacao): e = etree.SubElement(raiz, 'infEvento', Id=evento.identificador) etree.SubElement(e, 'cOrgao').text = CODIGOS_ESTADOS[evento.uf.upper()] etree.SubElement(e, 'tpAmb').text = str(self._ambiente) - etree.SubElement(e, 'CNPJ').text = evento.cnpj # Empresas somente terão CNPJ - #etree.SubElement(e, 'CPF').text = '' + if len(so_numeros(evento.cnpj)) == 11: + etree.SubElement(e, 'CPF').text = evento.cnpj + else: + etree.SubElement(e, 'CNPJ').text = evento.cnpj etree.SubElement(e, 'chNFe').text = evento.chave etree.SubElement(e, 'dhEvento').text = evento.data_emissao.strftime('%Y-%m-%dT%H:%M:%S') + tz etree.SubElement(e, 'tpEvento').text = evento.tp_evento