Browse Source

fix disable CE nfce

pull/206/head
marinaGD 7 years ago
parent
commit
5017f0f24a
  1. 12
      pytrustnfe/nfe/__init__.py
  2. 10
      pytrustnfe/nfe/patch.py
  3. 2
      setup.py

12
pytrustnfe/nfe/__init__.py

@ -6,6 +6,7 @@
import os
import requests
from lxml import etree
from .patch import nfeInutilizacaoCE
from .assinatura import Assinatura
from pytrustnfe.xml import render_xml, sanitize_response
from pytrustnfe.utils import gerar_chave, ChaveNFe
@ -94,11 +95,14 @@ def _send(certificado, method, **kwargs):
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
with client.settings(raw_response=True):
response = client.service[first_operation](xml)
response, obj = sanitize_response(response.text)
if kwargs["estado"] == '23':
response = nfeInutilizacaoCE(session, xml_send)
else:
response = client.service[first_operation](nfeDadosMsg=xml)
response_other, obj = sanitize_response(response.text)
return {
'sent_xml': xml_send,
'received_xml': response,
'sent_xml': xml_send, # response.request.body.decode('utf-8'),
'received_xml': response_other,
'object': obj.Body.getchildren()[0]
}

10
pytrustnfe/nfe/patch.py

@ -0,0 +1,10 @@
def nfeInutilizacaoCE(session, xml_send):
soap = '<Envelope xmlns="http://www.w3.org/2003/05/soap-envelope"><Body><nfeDadosMsg xmlns="http://www.portalfiscal.inf.br/nfe/wsdl/NFeInutilizacao4">' + xml_send + '</nfeDadosMsg></Body></Envelope>'
headers = {
'SOAPAction': "",
'Content-Type': 'application/soap+xml; charset="utf-8"'
}
response = session.post('https://nfeh.sefaz.ce.gov.br/nfe4/services/NFeInutilizacao4', data=soap, headers=headers)
return response

2
setup.py

@ -2,7 +2,7 @@
from setuptools import setup, find_packages
VERSION = "1.0.28"
VERSION = "1.0.29"
setup(

Loading…
Cancel
Save