Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Solução de contorno para Bahia e Paraná #50

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/erpbrasil/edoc/edoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ def _generateds_to_string_etree(self, ds, pretty_print=False):
return contents, etree.fromstring(contents)

def _post(self, raiz, url, operacao, classe):

# Estado do Paraná é obrigatório que o namespace seja definido tbm na tag NFE
if operacao == 'nfeAutorizacaoLote':
namespaceNFe = raiz.find(".//{http://www.portalfiscal.inf.br/nfe}NFe")
if namespaceNFe is not None:
namespaceNFe.set('xmlns', 'http://www.portalfiscal.inf.br/nfe')

Comment on lines +74 to +79
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aguadando confirmação que funciona em outros estados sem nenhuma regressão.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mileo teve alguma posição ?

xml_string, xml_etree = self._generateds_to_string_etree(raiz)
with self._transmissao.cliente(url):
retorno = self._transmissao.enviar(
Expand Down
6 changes: 5 additions & 1 deletion src/erpbrasil/edoc/nfe.py
Original file line number Diff line number Diff line change
Expand Up @@ -875,11 +875,15 @@ def enviar_lote_evento(self, lista_eventos, numero_lote=False):
xml_assinado = self.assina_raiz(evento, evento.infEvento.Id)
xml_envio_etree.append(etree.fromstring(xml_assinado))

operacao_recepcao_evento = 'nfeRecepcaoEvento'
if self.uf in [29, 41]:
operacao_recepcao_evento = 'nfeRecepcaoEventoNF'

return self._post(
xml_envio_etree,
localizar_url(WS_NFE_RECEPCAO_EVENTO, str(self.uf), self.mod,
int(self.ambiente)),
'nfeRecepcaoEvento',
operacao_recepcao_evento,
retEnvEvento
)

Expand Down
6 changes: 6 additions & 0 deletions src/erpbrasil/edoc/resposta.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ def analisar_retorno_raw(operacao, raiz, xml, retorno, classe):
retorno.raise_for_status()
match = re.search('<soap:Body>(.*?)</soap:Body>',
retorno.text.replace('\n', ''))

# Solução de contorno para estados que não se adequam ao padrão acima.
if not match:
match = re.search("<env:Body xmlns:env='http://www.w3.org/2003/05/soap-envelope'>(.*?)</env:Body>",
retorno.text.replace('\n', ''))

if match:
xml_resposta = match.group(1)
resultado = etree.tostring(etree.fromstring(xml_resposta)[0])
Expand Down