Browse Source

[RM] Removido NfeDownloadNF (substituido por NFeDistribuicaoDFe) NT2014.002

pull/41/head
juniortada 8 years ago
parent
commit
95097fc6e6
  1. 49
      pynfe/processamento/comunicacao.py
  2. 11
      pynfe/utils/webservices.py

49
pynfe/processamento/comunicacao.py

@ -70,18 +70,16 @@ class ComunicacaoSefaz(Comunicacao):
# Em caso de sucesso, retorna xml com nfe e protocolo de autorização.
# Caso contrário, envia todo o soap de resposta da Sefaz para decisão do usuário.
# import pdb
# pdb.set_trace()
if retorno.status_code == 200:
# namespace
ns = {'ns': NAMESPACE_NFE}
# Procuta status no xml
try:
prot = etree.fromstring(retorno.text)
except ValueError:
# em SP retorno.text apresenta erro
prot = etree.fromstring(retorno.content)
if ind_sinc == 1:
# Procuta status no xml
try:
prot = etree.fromstring(retorno.text)
except ValueError:
# em SP retorno.text apresenta erro
prot = etree.fromstring(retorno.content)
try:
# Protocolo com envio OK
inf_prot = prot[0][0] # root protNFe
@ -91,7 +89,7 @@ class ComunicacaoSefaz(Comunicacao):
prot_nfe = inf_prot.xpath("ns:retEnviNFe/ns:protNFe", namespaces=ns)[0]
status = prot_nfe.xpath('ns:infProt/ns:cStat', namespaces=ns)[0].text
# autorizado usa da NF-e
# retorna xml final (NFe+protNFe)
# retorna xml final (protNFe+NFe)
if status == '100':
raiz = etree.Element('nfeProc', xmlns=NAMESPACE_NFE, versao=VERSAO_PADRAO)
raiz.append(nota_fiscal)
@ -102,12 +100,7 @@ class ComunicacaoSefaz(Comunicacao):
return 1, retorno, nota_fiscal
else:
# Retorna id do protocolo para posterior consulta em caso de sucesso.
try:
rec = etree.fromstring(retorno.text)
except ValueError:
# em SP retorno.text apresenta erro
rec = etree.fromstring(retorno.content)
rec = rec[0][0]
rec = prot[0][0]
status = rec.xpath("ns:retEnviNFe/ns:cStat", namespaces=ns)[0].text
# Lote Recebido com Sucesso!
if status == '103':
@ -124,7 +117,7 @@ class ComunicacaoSefaz(Comunicacao):
Processamento".
:param modelo: Modelo da nota
:param numero: Número da nota
:return:
:return:
"""
# url do serviço
@ -273,30 +266,6 @@ class ComunicacaoSefaz(Comunicacao):
xml = self._construir_xml_soap('NFeStatusServico4', raiz)
return self._post(url, xml)
def download(self, cnpj, chave):
"""
Metodo para download de NFe por parte de destinatário.
O certificado digital deve ser o mesmo do destinatário da Nfe.
NT 2012/002
:param cnpj: CNPJ da empresa
:param chave: Chave
:return:
"""
# url do serviço
url = self._get_url_an(consulta='DOWNLOAD')
# Monta XML do corpo da requisição
raiz = etree.Element('downloadNFe', versao='1.00', xmlns=NAMESPACE_NFE)
etree.SubElement(raiz, 'tpAmb').text = str(self._ambiente)
etree.SubElement(raiz, 'xServ').text = 'DOWNLOAD NFE'
etree.SubElement(raiz, 'CNPJ').text = str(cnpj)
etree.SubElement(raiz, 'chNFe').text = str(chave)
# Monta XML para envio da requisição
xml = self._construir_xml_soap('NfeDownloadNF', raiz)
return self._post(url, xml)
def inutilizacao(self, modelo, cnpj, numero_inicial, numero_final, justificativa='', ano=None, serie='1'):
"""
Serviço destinado ao atendimento de solicitações de inutilização de numeração.

11
pynfe/utils/webservices.py

@ -280,12 +280,11 @@ NFCE = {
NFE = {
# Alguns serviços são disponibilizados apenas pelo ambiente nacional
'AN': {
'EVENTOS': 'nfe.fazenda.gov.br/NFeRecepcaoEvento4/NFeRecepcaoEvento4.asmx', # versao: 4.00
'DISTRIBUICAO': 'nfe.fazenda.gov.br/NFeDistribuicaoDFe/NFeDistribuicaoDFe.asmx',
'DOWNLOAD': 'nfe.fazenda.gov.br/NfeDownloadNF/NfeDownloadNF.asmx', # versao: 2.00/3.10
'DESTINADAS': 'nfe.fazenda.gov.br/NFeConsultaDest/NFeConsultaDest.asmx', # versao: 2.00/3.10
'HTTPS': 'https://www.',
'HOMOLOGACAO': 'https://hom.'
'EVENTOS': '.nfe.fazenda.gov.br/NFeRecepcaoEvento4/NFeRecepcaoEvento4.asmx', # versao: 4.00
'DISTRIBUICAO': '1.nfe.fazenda.gov.br/NFeDistribuicaoDFe/NFeDistribuicaoDFe.asmx',
'DESTINADAS': '.nfe.fazenda.gov.br/NFeConsultaDest/NFeConsultaDest.asmx', # versao: 2.00/3.10
'HTTPS': 'https://www',
'HOMOLOGACAO': 'https://hom'
},
'AM': {
'STATUS': 'nfe.sefaz.am.gov.br/services2/services/NfeStatusServico2',

Loading…
Cancel
Save