From 0be7f898c1822f47a384c69576a4a7d83d0dc885 Mon Sep 17 00:00:00 2001 From: El Mau Date: Mon, 14 Mar 2022 13:03:22 -0600 Subject: [PATCH] =?UTF-8?q?Agregar=20nuevos=20PDFs=20de=20documentaci?= =?UTF-8?q?=C3=B3n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...a_080322.pdf => Solicitud_Descarga_Masiva.pdf} | Bin source/cfdi-descarga.py | 2 +- source/sat/sat_web.py | 14 +++++++------- source/sat/util.py | 4 ++++ 4 files changed, 12 insertions(+), 8 deletions(-) rename doc/{Solicitud_Descarga_Masiva_080322.pdf => Solicitud_Descarga_Masiva.pdf} (100%) diff --git a/doc/Solicitud_Descarga_Masiva_080322.pdf b/doc/Solicitud_Descarga_Masiva.pdf similarity index 100% rename from doc/Solicitud_Descarga_Masiva_080322.pdf rename to doc/Solicitud_Descarga_Masiva.pdf diff --git a/source/cfdi-descarga.py b/source/cfdi-descarga.py index 3e85452..9e70eec 100755 --- a/source/cfdi-descarga.py +++ b/source/cfdi-descarga.py @@ -51,7 +51,7 @@ def _process_command_line_arguments(): dest='month', default=0, type=int, choices=range(13)) help = "Día de la descarga, de forma predeterminada no se usa" parser.add_argument('-d', '--dia', help=help, - dest='day', default=0, type=int, choices=range(32)) + dest='day', default=0, type=int, choices=range(31)) help = "Intervalo de días a partir de la fecha actual y hacia a atras" parser.add_argument('-ud', '--ultimos-dias', help=help, dest='last_days', default=0, type=int, choices=range(30)) diff --git a/source/sat/sat_web.py b/source/sat/sat_web.py index 0f0ea78..3e42bd1 100644 --- a/source/sat/sat_web.py +++ b/source/sat/sat_web.py @@ -36,7 +36,7 @@ class SATWebService(): 's': 'http://schemas.xmlsoap.org/soap/envelope/', 'u': 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd', 'o': 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd', - # ~ 'des': 'http://DescargaMasivaTerceros.sat.gob.mx', + 'des': 'http://DescargaMasivaTerceros.sat.gob.mx', 'xd': 'http://www.w3.org/2000/09/xmldsig#', } NS_RESULT = {'s': NS['s'], None: XMLNS} @@ -262,8 +262,6 @@ class SATWebService(): headers['Authorization'] = f'WRAP access_token="{self._token}"' data = self._get_data_req(args) - print(data.decode()) - response = httpx.post(self.URL['REQ'], data=data, headers=headers) if response.status_code != httpx.codes.OK: self._error = f'Status: {response.status_code} - {response.text}' @@ -277,7 +275,7 @@ class SATWebService(): return data def _get_data_verify(self, args): - NSMAP = {'s': self.NS['s'], 'des': self.NS['des'], 'xd': self.NS['xd']} + NSMAP = {'soapenv': self.NS['s'], 'des': self.NS['des'], 'xd': self.NS['xd']} node_name = f"{{{self.NS['s']}}}Envelope" root = ET.Element(node_name, nsmap=NSMAP) @@ -310,7 +308,8 @@ class SATWebService(): attr = {'Algorithm': 'http://www.w3.org/2000/09/xmldsig#rsa-sha1'} signature_method = ET.SubElement(signed_info, node_name, attr) - attr = {'URI': '#_0'} + # ~ attr = {'URI': '#_0'} + attr = {'URI': ''} reference = ET.SubElement(signed_info, 'Reference', attr) transforms = ET.SubElement(reference, 'Transforms') ET.SubElement(transforms, 'Transform', attr1) @@ -363,7 +362,7 @@ class SATWebService(): return data def _get_data_download(self, args): - NSMAP = {'s': self.NS['s'], 'des': self.NS['des'], 'xd': self.NS['xd']} + NSMAP = {'soapenv': self.NS['s'], 'des': self.NS['des'], 'xd': self.NS['xd']} node_name = f"{{{self.NS['s']}}}Envelope" root = ET.Element(node_name, nsmap=NSMAP) @@ -396,7 +395,8 @@ class SATWebService(): attr = {'Algorithm': 'http://www.w3.org/2000/09/xmldsig#rsa-sha1'} signature_method = ET.SubElement(signed_info, node_name, attr) - attr = {'URI': '#_0'} + # ~ attr = {'URI': '#_0'} + attr = {'URI': ''} reference = ET.SubElement(signed_info, 'Reference', attr) transforms = ET.SubElement(reference, 'Transforms') ET.SubElement(transforms, 'Transform', attr1) diff --git a/source/sat/util.py b/source/sat/util.py index 3328694..0cf37a2 100644 --- a/source/sat/util.py +++ b/source/sat/util.py @@ -342,6 +342,10 @@ def descargar_archivos(args): else: result = sat.verify(data) files = result['files'] + if result['EstadoSolicitud'] in ('1', '2'): + msg = 'Solicitud aún no aceptada...' + log.error(msg) + return for f in files: data['id_file'] = f