Agregar declaración de encoding XML para cancelación

This commit is contained in:
El Mau 2021-11-25 12:51:49 -06:00
parent 264090f2a6
commit d2bacc3b6b
3 changed files with 6 additions and 5 deletions

View File

@ -4,6 +4,7 @@ import argparse
import base64
import datetime
import getpass
import hashlib
import subprocess
from pathlib import Path
@ -170,6 +171,7 @@ class SATCertificate(object):
xml_signed = ET.tostring(
tree, encoding='utf-8', xml_declaration=True).decode()
xml_signed = xml_signed.replace("'", '"').replace('utf', 'UTF')
return xml_signed

View File

@ -695,8 +695,8 @@ def cancel_xml_sign(invoice, auth, certificado):
template = TEMPLATE_CANCEL.format(**data)
tree = ET.fromstring(template.encode())
sign_xml = cert.sign_xml(tree)
result = pac.cancel_xml(sign_xml, auth, invoice.xml)
if pac.error:
data = {'ok': False, 'msg': pac.error, 'row': {}}
return data

View File

@ -307,5 +307,4 @@ TEMPLATE_CANCEL = """<Cancelacion xmlns="http://cancelacfd.sat.gob.mx" xmlns:xsd
</KeyInfo>
</Signature>
</Cancelacion>
"""