Fix - Query SAT
This commit is contained in:
parent
2ddb3d6b75
commit
e3bd1e8871
|
@ -841,9 +841,9 @@ def make_xml(data, certificado):
|
||||||
def get_pac_by_rfc(cfdi):
|
def get_pac_by_rfc(cfdi):
|
||||||
tree = ET.fromstring(cfdi.encode())
|
tree = ET.fromstring(cfdi.encode())
|
||||||
version = tree.attrib['Version']
|
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)'
|
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]
|
return RFCS[rfc_pac]
|
||||||
|
|
||||||
|
|
||||||
|
@ -909,17 +909,20 @@ def cancel_xml_sign(invoice, args, auth, certificado):
|
||||||
|
|
||||||
def _get_data_sat(xml):
|
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())
|
||||||
|
version = tree.attrib['Version']
|
||||||
|
namespaces = {'cfdi': PRE[version][1:-1]}
|
||||||
|
|
||||||
emisor = escape(
|
emisor = escape(
|
||||||
tree.xpath('string(//cfdi:Emisor/@rfc)', namespaces=NS_CFDI) or
|
tree.xpath('string(//cfdi:Emisor/@rfc)', namespaces=namespaces) or
|
||||||
tree.xpath('string(//cfdi:Emisor/@Rfc)', namespaces=NS_CFDI)
|
tree.xpath('string(//cfdi:Emisor/@Rfc)', namespaces=namespaces)
|
||||||
)
|
)
|
||||||
receptor = escape(
|
receptor = escape(
|
||||||
tree.xpath('string(//cfdi:Receptor/@rfc)', namespaces=NS_CFDI) or
|
tree.xpath('string(//cfdi:Receptor/@rfc)', namespaces=namespaces) or
|
||||||
tree.xpath('string(//cfdi:Receptor/@Rfc)', namespaces=NS_CFDI)
|
tree.xpath('string(//cfdi:Receptor/@Rfc)', namespaces=namespaces)
|
||||||
)
|
)
|
||||||
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'))
|
||||||
|
|
Loading…
Reference in New Issue