Error: Consulta de estatus en el SAT

This commit is contained in:
Mauricio Baeza 2018-11-06 22:56:43 -06:00
parent 47ed1cb72e
commit 68ed8ee0db
4 changed files with 32 additions and 7 deletions

View File

@ -1,3 +1,8 @@
v 1.24.0 [06-nov-2018]
----------------------
- Fix: Consulta estatus SAT
v 1.23.0 [30-oct-2018] v 1.23.0 [30-oct-2018]
---------------------- ----------------------
- Mejora: Permitir importar CFDI 3.2 - Mejora: Permitir importar CFDI 3.2

View File

@ -1 +1 @@
1.23.0 1.24.0

View File

@ -709,7 +709,7 @@ def _get_data_sat(path):
print (e) print (e)
return {} return {}
return '?re={emisor}&rr={receptor}&tt={total}&id={uuid}'.format(**data) return '?re={emisor}&rr={receptor}&tt={total}&id={uuid}'.format(**data)
def get_status_sat(xml): def get_status_sat(xml):
@ -717,14 +717,34 @@ def get_status_sat(xml):
if not data: if not data:
return 'XML inválido' return 'XML inválido'
URL = 'https://consultaqr.facturaelectronica.sat.gob.mx/ConsultaCFDIService.svc?wsdl' data = """<?xml version="1.0" encoding="UTF-8"?>
client = Client(URL, transport=Transport(cache=SqliteCache())) <soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap:Header/>
<soap:Body>
<Consulta xmlns="http://tempuri.org/">
<expresionImpresa>
{}
</expresionImpresa>
</Consulta>
</soap:Body>
</soap:Envelope>""".format(data)
headers = {
'SOAPAction': '"http://tempuri.org/IConsultaCFDIService/Consulta"',
'Content-type': 'text/xml; charset="UTF-8"'
}
URL = 'https://consultaqr.facturaelectronica.sat.gob.mx/consultacfdiservice.svc'
try: try:
result = client.service.Consulta(expresionImpresa=data) result = requests.post(URL, data=data, headers=headers)
tree = etree.fromstring(result.text)
node = tree.xpath("//*[local-name() = 'Estado']")[0]
except Exception as e: except Exception as e:
return 'Error: {}'.format(str(e)) return 'Error: {}'.format(str(e))
return result.Estado return node.text
def main(): def main():

View File

@ -47,7 +47,7 @@ except ImportError:
DEBUG = DEBUG DEBUG = DEBUG
VERSION = '1.23.0' VERSION = '1.24.0'
EMAIL_SUPPORT = ('soporte@empresalibre.net',) EMAIL_SUPPORT = ('soporte@empresalibre.net',)
TITLE_APP = '{} v{}'.format(TITLE_APP, VERSION) TITLE_APP = '{} v{}'.format(TITLE_APP, VERSION)