Fix - Query SAT

This commit is contained in:
el Mau 2022-10-25 20:22:48 -05:00
parent 2ddb3d6b75
commit e3bd1e8871
1 changed files with 10 additions and 7 deletions

View File

@ -841,9 +841,9 @@ def make_xml(data, certificado):
def get_pac_by_rfc(cfdi):
tree = ET.fromstring(cfdi.encode())
version = tree.attrib['Version']
NAME_SPACES = {'cfdi': PRE[version][1:-1], 'tdf': PRE['TIMBRE'][1:-1]}
namespaces = {'cfdi': PRE[version][1:-1], 'tdf': PRE['TIMBRE'][1:-1]}
path = 'string(//cfdi:Complemento/tdf:TimbreFiscalDigital/@RfcProvCertif)'
rfc_pac = tree.xpath(path, namespaces=NAME_SPACES)
rfc_pac = tree.xpath(path, namespaces=namespaces)
return RFCS[rfc_pac]
@ -909,17 +909,20 @@ def cancel_xml_sign(invoice, args, auth, certificado):
def _get_data_sat(xml):
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:
tree = ET.fromstring(xml.encode())
version = tree.attrib['Version']
namespaces = {'cfdi': PRE[version][1:-1]}
emisor = escape(
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=namespaces) or
tree.xpath('string(//cfdi:Emisor/@Rfc)', namespaces=namespaces)
)
receptor = escape(
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=namespaces) or
tree.xpath('string(//cfdi:Receptor/@Rfc)', namespaces=namespaces)
)
total = tree.get('total') or tree.get('Total')
uuid = tree.xpath(BF.format('TimbreFiscalDigital', 'UUID'))