Fix - Cancel v4.0
This commit is contained in:
parent
4cda9f7f21
commit
2ddb3d6b75
|
@ -41,6 +41,12 @@ logging.getLogger('requests').setLevel(logging.ERROR)
|
|||
|
||||
TIMEOUT = 10
|
||||
|
||||
NAMESPACES = {
|
||||
'3.3': 'http://www.sat.gob.mx/cfd/3',
|
||||
'4.0': 'http://www.sat.gob.mx/cfd/4',
|
||||
'tdf': 'http://www.sat.gob.mx/TimbreFiscalDigital',
|
||||
}
|
||||
|
||||
|
||||
def pretty_print_POST(req):
|
||||
"""
|
||||
|
@ -175,26 +181,29 @@ class PACComercioDigital(object):
|
|||
info['key'] = base64.b64encode(info['key_enc']).decode()
|
||||
info['cer'] = base64.b64encode(info['cer_ori']).decode()
|
||||
|
||||
NS_CFDI = {
|
||||
'cfdi': 'http://www.sat.gob.mx/cfd/3',
|
||||
'tdf': 'http://www.sat.gob.mx/TimbreFiscalDigital',
|
||||
}
|
||||
tree = ET.fromstring(cfdi.encode())
|
||||
version = tree.attrib['Version']
|
||||
|
||||
namespaces = {
|
||||
'cfdi': NAMESPACES[version],
|
||||
'tdf': NAMESPACES['tdf'],
|
||||
}
|
||||
|
||||
tipo = tree.xpath(
|
||||
'string(//cfdi:Comprobante/@TipoDeComprobante)',
|
||||
namespaces=NS_CFDI)
|
||||
namespaces=namespaces)
|
||||
total = tree.xpath(
|
||||
'string(//cfdi:Comprobante/@Total)',
|
||||
namespaces=NS_CFDI)
|
||||
namespaces=namespaces)
|
||||
rfc_emisor = tree.xpath(
|
||||
'string(//cfdi:Comprobante/cfdi:Emisor/@Rfc)',
|
||||
namespaces=NS_CFDI)
|
||||
namespaces=namespaces)
|
||||
rfc_receptor = tree.xpath(
|
||||
'string(//cfdi:Comprobante/cfdi:Receptor/@Rfc)',
|
||||
namespaces=NS_CFDI)
|
||||
namespaces=namespaces)
|
||||
uid = tree.xpath(
|
||||
'string(//cfdi:Complemento/tdf:TimbreFiscalDigital/@UUID)',
|
||||
namespaces=NS_CFDI)
|
||||
namespaces=namespaces)
|
||||
data = (
|
||||
f"USER={auth['user']}",
|
||||
f"PWDW={auth['pass']}",
|
||||
|
|
|
@ -55,7 +55,7 @@ from dateutil import parser
|
|||
|
||||
from .cfdi_xml import CFDI
|
||||
|
||||
from settings import DEBUG, DB_COMPANIES, PATHS, TEMPLATE_CANCEL, RFCS
|
||||
from settings import DEBUG, DB_COMPANIES, PATHS, TEMPLATE_CANCEL, RFCS, PRE
|
||||
|
||||
from .pacs.cfdi_cert import SATCertificate
|
||||
from .pacs import PACComercioDigital
|
||||
|
@ -88,6 +88,7 @@ PACS = {
|
|||
'finkok': PACFinkok,
|
||||
'comercio': PACComercioDigital,
|
||||
}
|
||||
|
||||
NS_CFDI = {
|
||||
'cfdi': 'http://www.sat.gob.mx/cfd/3',
|
||||
'tdf': 'http://www.sat.gob.mx/TimbreFiscalDigital',
|
||||
|
@ -839,8 +840,10 @@ 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]}
|
||||
path = 'string(//cfdi:Complemento/tdf:TimbreFiscalDigital/@RfcProvCertif)'
|
||||
rfc_pac = tree.xpath(path, namespaces=NS_CFDI)
|
||||
rfc_pac = tree.xpath(path, namespaces=NAME_SPACES)
|
||||
return RFCS[rfc_pac]
|
||||
|
||||
|
||||
|
|
|
@ -10680,7 +10680,7 @@ def get_cp(cp):
|
|||
cursor = con.cursor()
|
||||
sql = """SELECT estado, municipio, clave, colonia, key_estado
|
||||
FROM codigos, colonias, municipios, estados
|
||||
WHERE colonias.id_cp=codigos.id
|
||||
WHERE codigos.id_colonia=colonias.id
|
||||
AND codigos.id_municipio=municipios.id
|
||||
AND municipios.id_estado=estados.id
|
||||
AND cp=?
|
||||
|
@ -10703,7 +10703,7 @@ def get_cp(cp):
|
|||
else:
|
||||
data['colonia'] = [r[3] for r in rows]
|
||||
|
||||
print('DATA', data)
|
||||
print('CP', cp, data)
|
||||
|
||||
return data
|
||||
|
||||
|
|
BIN
source/db/cp.db
BIN
source/db/cp.db
Binary file not shown.
Loading…
Reference in New Issue