Error al timbrar Carta Porte
This commit is contained in:
parent
702aa264d8
commit
a38247727c
|
@ -1,6 +1,9 @@
|
|||
v 1.45.4 [24-Ene-2022]
|
||||
v 1.45.4 [25-Ene-2022]
|
||||
----------------------
|
||||
- Error: Cambio de NameSpace del XML de cancelación
|
||||
- Error: Al timbrar carta porte.
|
||||
- Error: Al cancelar con Comercio Digital.
|
||||
|
||||
* IMPORTANTE: Es necesario subir de nuevo tus certificados de sello, **solo** si timbras con Comercio Digital.
|
||||
|
||||
|
||||
v 1.45.3 [23-Ene-2022]
|
||||
|
|
|
@ -28,18 +28,18 @@ class SATCertificate(object):
|
|||
self._init_values()
|
||||
self._get_data_cer(cer)
|
||||
self._get_data_key(key, password)
|
||||
if not password:
|
||||
self._test()
|
||||
# ~ if not password:
|
||||
# ~ self._test()
|
||||
|
||||
def _test(self):
|
||||
key = self._get_key('')
|
||||
self._p = TOKEN
|
||||
self._key_der = key.private_bytes(
|
||||
encoding=serialization.Encoding.DER,
|
||||
format=serialization.PrivateFormat.PKCS8,
|
||||
encryption_algorithm=serialization.BestAvailableEncryption(self._p.encode())
|
||||
)
|
||||
return
|
||||
# ~ def _test(self):
|
||||
# ~ key = self._get_key('')
|
||||
# ~ self._p = ''
|
||||
# ~ self._key_der = key.private_bytes(
|
||||
# ~ encoding=serialization.Encoding.DER,
|
||||
# ~ format=serialization.PrivateFormat.PKCS8,
|
||||
# ~ encryption_algorithm=serialization.BestAvailableEncryption(self._p.encode())
|
||||
# ~ )
|
||||
# ~ return
|
||||
|
||||
def _init_values(self):
|
||||
self._rfc = ''
|
||||
|
@ -52,6 +52,7 @@ class SATCertificate(object):
|
|||
self._is_fiel = False
|
||||
self._are_couple = False
|
||||
self._is_valid_time = False
|
||||
self._key = b''
|
||||
self._cer = b''
|
||||
self._cer_pem = ''
|
||||
self._cer_txt = ''
|
||||
|
@ -110,6 +111,8 @@ class SATCertificate(object):
|
|||
return
|
||||
|
||||
def _get_data_key(self, key, password):
|
||||
self._key = key
|
||||
self._keyp = password
|
||||
self._key_enc = key
|
||||
if not key or not password:
|
||||
return
|
||||
|
|
|
@ -110,9 +110,10 @@ class PACComercioDigital(object):
|
|||
headers['Connection'] = 'Keep-Alive'
|
||||
headers['Expect'] = '100-continue'
|
||||
|
||||
req = requests.Request('POST', url, headers=headers, data=data)
|
||||
prepared = req.prepare()
|
||||
pretty_print_POST(prepared)
|
||||
if DEBUG:
|
||||
req = requests.Request('POST', url, headers=headers, data=data)
|
||||
prepared = req.prepare()
|
||||
pretty_print_POST(prepared)
|
||||
|
||||
try:
|
||||
result = requests.post(url, data=data, headers=headers, timeout=TIMEOUT)
|
||||
|
|
|
@ -767,7 +767,7 @@ def _cancel_with_cert(invoice, args, auth, certificado):
|
|||
pac = PACS[auth['pac']]()
|
||||
# ~ info = {'cer': cert.cer_pem, 'key': cert.key_pem, 'pass': '', 'args': args}
|
||||
info = {'cer': cert.cer_pem, 'key': cert.key_pem, 'cer_ori': cert.cer,
|
||||
'key_enc': cert._key_der, 'pass': cert._p, 'args': args}
|
||||
'key_enc': certificado.key, 'pass': decrypt(bytes(certificado.p12).decode(), certificado.serie), 'args': args}
|
||||
|
||||
result = pac.cancel(invoice.xml, info, auth)
|
||||
if pac.error:
|
||||
|
@ -796,11 +796,11 @@ def cancel_xml_sign(invoice, args, auth, certificado):
|
|||
'motivo': args['reason'],
|
||||
'folio': folio_new,
|
||||
}
|
||||
|
||||
template = TEMPLATE_CANCEL.format(**data)
|
||||
tree = ET.fromstring(template.encode())
|
||||
sign_xml = cert.sign_xml(tree)
|
||||
# ~ print(sign_xml)
|
||||
|
||||
result = pac.cancel_xml(sign_xml, auth, invoice.xml)
|
||||
|
||||
if pac.error:
|
||||
|
|
|
@ -1167,9 +1167,12 @@ class Certificado(BaseModel):
|
|||
result['msg'] = 'El RFC del certificado no corresponde.'
|
||||
return result
|
||||
|
||||
obj.key = cert._key
|
||||
obj.key_enc = cert.key_enc
|
||||
obj.cer = cert.cer
|
||||
obj.serie = cert.serial_number
|
||||
obj.cer_txt = cert.cer_txt
|
||||
obj.p12 = utils.encrypt(cert._keyp, cert.serial_number)
|
||||
obj.desde = cert.not_before
|
||||
obj.hasta = cert.not_after
|
||||
obj.save()
|
||||
|
@ -5357,7 +5360,7 @@ class Facturas(BaseModel):
|
|||
|
||||
ubicaciones = values['ubicaciones']
|
||||
for ubicacion in ubicaciones:
|
||||
if 'DistanciaRecorrida' in ubicacion:
|
||||
if 'DistanciaRecorrida' in ubicacion and ubicacion['DistanciaRecorrida'].strip():
|
||||
total_distance += float(ubicacion['DistanciaRecorrida'])
|
||||
if isinstance(ubicacion['DistanciaRecorrida'], (int, float)):
|
||||
ubicacion['DistanciaRecorrida'] = f"{ubicacion['DistanciaRecorrida']:.2f}"
|
||||
|
|
|
@ -293,4 +293,4 @@ DEFAULT_GLOBAL = {
|
|||
# ~ </Cancelacion>
|
||||
# ~ </CancelaCFD>"""
|
||||
|
||||
TEMPLATE_CANCEL = """<CancelaCFD xmlns="http://cancelacfd.sat.gob.mx"><Cancelacion xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" RfcEmisor="{rfc}" Fecha="{fecha}"><Folios><Folio UUID="{uuid}" Motivo="{motivo}"{folio}/></Folios><Signature xmlns="http://www.w3.org/2000/09/xmldsig#"><SignedInfo><CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315" /><SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" /><Reference URI=""><Transforms><Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" /></Transforms><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" /><DigestValue/></Reference></SignedInfo><SignatureValue/><KeyInfo><X509Data><X509IssuerSerial><X509IssuerName/><X509SerialNumber/></X509IssuerSerial><X509Certificate/></X509Data><KeyValue><RSAKeyValue><Modulus/><Exponent/></RSAKeyValue></KeyValue></KeyInfo></Signature></Cancelacion></CancelaCFD>"""
|
||||
TEMPLATE_CANCEL = """<CancelaCFD xmlns="http://cancelacfd.sat.gob.mx"><Cancelacion xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Fecha="{fecha}" RfcEmisor="{rfc}" xmlns="http://cancelacfd.sat.gob.mx"><Folios><Folio UUID="{uuid}" Motivo="{motivo}"{folio}/></Folios><Signature xmlns="http://www.w3.org/2000/09/xmldsig#"><SignedInfo><CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315" /><SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" /><Reference URI=""><Transforms><Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" /></Transforms><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" /><DigestValue/></Reference></SignedInfo><SignatureValue/><KeyInfo><X509Data><X509IssuerSerial><X509IssuerName/><X509SerialNumber/></X509IssuerSerial><X509Certificate/></X509Data><KeyValue><RSAKeyValue><Modulus/><Exponent/></RSAKeyValue></KeyValue></KeyInfo></Signature></Cancelacion></CancelaCFD>"""
|
||||
|
|
|
@ -746,7 +746,7 @@ var opt_clave_entidad = [
|
|||
{id: 'GRO', value: 'Guerrero'},
|
||||
{id: 'HID', value: 'Hidalgo'},
|
||||
{id: 'JAL', value: 'Jalisco'},
|
||||
{id: 'MEX', value: 'México'},
|
||||
{id: 'MEX', value: 'Estado de México'},
|
||||
{id: 'MIC', value: 'Michoacán'},
|
||||
{id: 'MOR', value: 'Morelos'},
|
||||
{id: 'NAC', value: 'Nacional'},
|
||||
|
|
Loading…
Reference in New Issue