forked from elmau/empresa-libre
Add try except
This commit is contained in:
parent
f0b5fa5ae9
commit
0bbf0b438f
|
@ -705,20 +705,20 @@ 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 = ET.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)
|
||||||
)
|
)
|
||||||
receptor = escape(
|
receptor = escape(
|
||||||
tree.xpath('string(//cfdi:Receptor/@rfc)', namespaces=NS_CFDI) or
|
tree.xpath('string(//cfdi:Receptor/@rfc)', namespaces=NS_CFDI) or
|
||||||
tree.xpath('string(//cfdi:Receptor/@Rfc)', namespaces=NS_CFDI)
|
tree.xpath('string(//cfdi:Receptor/@Rfc)', namespaces=NS_CFDI)
|
||||||
)
|
)
|
||||||
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
|
||||||
|
|
Loading…
Reference in New Issue