Agregar declaración de encoding XML para cancelación
This commit is contained in:
parent
264090f2a6
commit
d2bacc3b6b
|
@ -4,6 +4,7 @@ import argparse
|
||||||
import base64
|
import base64
|
||||||
import datetime
|
import datetime
|
||||||
import getpass
|
import getpass
|
||||||
|
import hashlib
|
||||||
import subprocess
|
import subprocess
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
@ -170,6 +171,7 @@ class SATCertificate(object):
|
||||||
|
|
||||||
xml_signed = ET.tostring(
|
xml_signed = ET.tostring(
|
||||||
tree, encoding='utf-8', xml_declaration=True).decode()
|
tree, encoding='utf-8', xml_declaration=True).decode()
|
||||||
|
xml_signed = xml_signed.replace("'", '"').replace('utf', 'UTF')
|
||||||
|
|
||||||
return xml_signed
|
return xml_signed
|
||||||
|
|
||||||
|
|
|
@ -695,8 +695,8 @@ def cancel_xml_sign(invoice, auth, certificado):
|
||||||
template = TEMPLATE_CANCEL.format(**data)
|
template = TEMPLATE_CANCEL.format(**data)
|
||||||
tree = ET.fromstring(template.encode())
|
tree = ET.fromstring(template.encode())
|
||||||
sign_xml = cert.sign_xml(tree)
|
sign_xml = cert.sign_xml(tree)
|
||||||
|
|
||||||
result = pac.cancel_xml(sign_xml, auth, invoice.xml)
|
result = pac.cancel_xml(sign_xml, auth, invoice.xml)
|
||||||
|
|
||||||
if pac.error:
|
if pac.error:
|
||||||
data = {'ok': False, 'msg': pac.error, 'row': {}}
|
data = {'ok': False, 'msg': pac.error, 'row': {}}
|
||||||
return data
|
return data
|
||||||
|
|
|
@ -286,12 +286,12 @@ TEMPLATE_CANCEL = """<Cancelacion xmlns="http://cancelacfd.sat.gob.mx" xmlns:xsd
|
||||||
<Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
|
<Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
|
||||||
<SignedInfo>
|
<SignedInfo>
|
||||||
<CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
|
<CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
|
||||||
<SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
|
<SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" />
|
||||||
<Reference URI="">
|
<Reference URI="">
|
||||||
<Transforms>
|
<Transforms>
|
||||||
<Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
|
<Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" />
|
||||||
</Transforms>
|
</Transforms>
|
||||||
<DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
|
<DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
|
||||||
<DigestValue/>
|
<DigestValue/>
|
||||||
</Reference>
|
</Reference>
|
||||||
</SignedInfo>
|
</SignedInfo>
|
||||||
|
@ -307,5 +307,4 @@ TEMPLATE_CANCEL = """<Cancelacion xmlns="http://cancelacfd.sat.gob.mx" xmlns:xsd
|
||||||
</KeyInfo>
|
</KeyInfo>
|
||||||
</Signature>
|
</Signature>
|
||||||
</Cancelacion>
|
</Cancelacion>
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue