Fix - issue #422
This commit is contained in:
parent
7f44f7f26d
commit
f0b5fa5ae9
|
@ -32,7 +32,7 @@ import subprocess
|
||||||
import threading
|
import threading
|
||||||
import zipfile
|
import zipfile
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from urllib import request
|
from xml.sax.saxutils import escape
|
||||||
|
|
||||||
from email.mime.multipart import MIMEMultipart
|
from email.mime.multipart import MIMEMultipart
|
||||||
from email.mime.base import MIMEBase
|
from email.mime.base import MIMEBase
|
||||||
|
@ -705,8 +705,8 @@ def _get_data_sat(xml):
|
||||||
BF = 'string(//*[local-name()="{}"]/@{})'
|
BF = 'string(//*[local-name()="{}"]/@{})'
|
||||||
NS_CFDI = {'cfdi': 'http://www.sat.gob.mx/cfd/3'}
|
NS_CFDI = {'cfdi': 'http://www.sat.gob.mx/cfd/3'}
|
||||||
|
|
||||||
try:
|
# ~ try:
|
||||||
tree = etree.fromstring(xml.encode())
|
tree = ET.fromstring(xml.encode())
|
||||||
emisor = escape(
|
emisor = escape(
|
||||||
tree.xpath('string(//cfdi:Emisor/@rfc)', namespaces=NS_CFDI) or
|
tree.xpath('string(//cfdi:Emisor/@rfc)', namespaces=NS_CFDI) or
|
||||||
tree.xpath('string(//cfdi:Emisor/@Rfc)', namespaces=NS_CFDI)
|
tree.xpath('string(//cfdi:Emisor/@Rfc)', namespaces=NS_CFDI)
|
||||||
|
@ -717,8 +717,8 @@ def _get_data_sat(xml):
|
||||||
)
|
)
|
||||||
total = tree.get('total') or tree.get('Total')
|
total = tree.get('total') or tree.get('Total')
|
||||||
uuid = tree.xpath(BF.format('TimbreFiscalDigital', 'UUID'))
|
uuid = tree.xpath(BF.format('TimbreFiscalDigital', 'UUID'))
|
||||||
except Exception as e:
|
# ~ except Exception as e:
|
||||||
return ''
|
# ~ return ''
|
||||||
|
|
||||||
data = f'?re={emisor}&rr={receptor}&tt={total}&id={uuid}'
|
data = f'?re={emisor}&rr={receptor}&tt={total}&id={uuid}'
|
||||||
return data
|
return data
|
||||||
|
@ -751,7 +751,7 @@ def get_status_sat(xml):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
result = requests.post(URL, data=data, headers=headers)
|
result = requests.post(URL, data=data, headers=headers)
|
||||||
tree = etree.fromstring(result.text)
|
tree = ET.fromstring(result.text)
|
||||||
node = tree.xpath("//*[local-name() = 'Estado']")[0]
|
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))
|
||||||
|
|
Loading…
Reference in New Issue