diff --git a/CHANGELOG.md b/CHANGELOG.md index 75e154c..b125ece 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Lista de cambios +## v 0.6.0 [10-Mar-22] +--- +* Fix - Cambios del SAT + ## v 0.5.1 [09-Feb-22] --- diff --git a/VERSION b/VERSION index 4b9fcbe..a918a2a 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.5.1 +0.6.0 diff --git a/doc/Servicio+de+Descarga+de+Solicitudes+Exitosas.pdf b/doc/Servicio+de+Descarga+de+Solicitudes+Exitosas.pdf new file mode 100644 index 0000000..36eafc0 Binary files /dev/null and b/doc/Servicio+de+Descarga+de+Solicitudes+Exitosas.pdf differ diff --git a/doc/Servicio+de+Verificación+de+Descarga+de+Solicitudes+Exitosas.pdf b/doc/Servicio+de+Verificación+de+Descarga+de+Solicitudes+Exitosas.pdf new file mode 100644 index 0000000..173b3f6 Binary files /dev/null and b/doc/Servicio+de+Verificación+de+Descarga+de+Solicitudes+Exitosas.pdf differ diff --git a/doc/Solicitud_Descarga_Masiva_080322.pdf b/doc/Solicitud_Descarga_Masiva_080322.pdf new file mode 100644 index 0000000..7c87e49 Binary files /dev/null and b/doc/Solicitud_Descarga_Masiva_080322.pdf differ diff --git a/doc/URLs.pdf b/doc/URLs.pdf new file mode 100644 index 0000000..b13ab37 Binary files /dev/null and b/doc/URLs.pdf differ diff --git a/source/sat/sat_web.py b/source/sat/sat_web.py index 7f4b92c..0f0ea78 100644 --- a/source/sat/sat_web.py +++ b/source/sat/sat_web.py @@ -29,12 +29,14 @@ class SATWebService(): 'Content-type': 'text/xml;charset="utf-8"', 'Accept': 'text/xml', 'Cache-Control': 'no-cache', + 'Expect': '100-continue', + 'Accept-Encoding': 'gzip, deflate', } NS = { '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} @@ -148,12 +150,14 @@ class SATWebService(): nsmap = {'s': self.NS['s'], None: self.XMLNS} node_name = 's:Body/AutenticaResponse/AutenticaResult' token = result.find(node_name, namespaces=nsmap).text - print(f'Token: {token}') + # ~ print(f'Token: {token}') return token def _get_data_req(self, args): - NSMAP = {'s': self.NS['s'], 'des': self.NS['des'], 'xd': self.NS['xd']} + # ~ NSMAP = {'s': self.NS['s'], 'des': self.NS['des'], 'xd': self.NS['xd']} + # ~ NSMAP = {'s': self.NS['s'], 'xd': self.NS['xd']} + NSMAP = {'s': self.NS['s']} FORMAT = '%Y-%m-%dT%H:%M:%S' date_start = args['date_start'] @@ -165,28 +169,46 @@ class SATWebService(): root = ET.Element(node_name, nsmap=NSMAP) node_name = f"{{{self.NS['s']}}}Header" - body = ET.SubElement(root, node_name) + header = ET.SubElement(root, node_name) + node_name = 'ActivityId' + attr = {'CorrelationId': '806aad0d-ef46-443b-9741-040c8e8e8c7d'} + nsmap = {None: 'http://schemas.microsoft.com/2004/09/ServiceModel/Diagnostics'} + activity = ET.SubElement(header, node_name, attr, nsmap=nsmap) + activity.text = 'e906cfb4-f706-43de-94d0-5cc935be1aaa' node_name = f"{{{self.NS['s']}}}Body" - body = ET.SubElement(root, node_name) + nsmap = { + 'xsi': 'http://www.w3.org/2001/XMLSchema-instance', + 'xsd': 'http://www.w3.org/2001/XMLSchema', + } + body = ET.SubElement(root, node_name, nsmap=nsmap) - node_name = f"{{{self.NS['des']}}}SolicitaDescarga" - request_down = ET.SubElement(body, node_name) + # ~ node_name = f"{{{self.NS['des']}}}SolicitaDescarga" + node_name = "SolicitaDescarga" + nsmap = {None: 'http://DescargaMasivaTerceros.sat.gob.mx'} + request_down = ET.SubElement(body, node_name, nsmap=nsmap) - node_name = f"{{{self.NS['des']}}}solicitud" + # ~ node_name = f"{{{self.NS['des']}}}solicitud" + node_name = "solicitud" type_request = 'CFDI' if args['metadata']: type_request = 'Metadata' attr = { - 'RfcSolicitante': self._cert.rfc, - 'FechaFinal': date_end.strftime(FORMAT), 'FechaInicial': date_start.strftime(FORMAT), - 'TipoSolicitud': type_request, + 'FechaFinal': date_end.strftime(FORMAT), args['rfc']: self._cert.rfc, + 'RfcSolicitante': self._cert.rfc, + 'TipoSolicitud': type_request, + 'RfcACuentaTerceros': '', } request = ET.SubElement(request_down, node_name, attr) + node_name = 'RfcReceptores' + node_receptores = ET.SubElement(request, node_name) + node_name = 'RfcReceptor' + ET.SubElement(node_receptores, node_name) + nsmap = {None: self.NS['xd']} signature = ET.SubElement(request, 'Signature', nsmap=nsmap) signed_info = ET.SubElement(signature, 'SignedInfo', nsmap=nsmap) @@ -199,7 +221,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) @@ -235,9 +258,12 @@ class SATWebService(): def request_download(self, args): headers = self.HEADERS.copy() headers['SOAPAction'] = self.ACTIONS['REQ'] + headers['Host'] = 'srvsolicituddescargamaster.cloudapp.net' 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}'