From 88dd9ca04bbfcd748cf7ddfc0248aa244c500eb3 Mon Sep 17 00:00:00 2001 From: El Mau Date: Thu, 20 Jan 2022 13:22:51 -0600 Subject: [PATCH 1/2] Corregir el error al enviar correo --- CHANGELOG.md | 8 ++++++++ VERSION | 2 +- source/app/controllers/pacs/comerciodigital/comercio.py | 2 +- source/app/controllers/utils.py | 4 ---- source/app/models/main.py | 5 ++++- source/app/settings.py | 2 +- 6 files changed, 15 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e056e9f..f5e4557 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +v 1.45.1 [20-Ene-2022] +---------------------- + - Error: Al enviar correos con la nueva configuración + - Error: Al cancelar CFDI + +* IMPORTANTE: Revisa tu configuración de correo para verificar que todo funcione. + + v 1.45.0 [20-Ene-2022] ---------------------- - Importar Carta Porte desde archivo JSON diff --git a/VERSION b/VERSION index 3e59ccd..0c15f2f 100644 --- a/VERSION +++ b/VERSION @@ -1,2 +1,2 @@ -1.45.0 +1.45.1 diff --git a/source/app/controllers/pacs/comerciodigital/comercio.py b/source/app/controllers/pacs/comerciodigital/comercio.py index 0d1c48f..595624b 100644 --- a/source/app/controllers/pacs/comerciodigital/comercio.py +++ b/source/app/controllers/pacs/comerciodigital/comercio.py @@ -245,7 +245,7 @@ class PACComercioDigital(object): return headers - def cancel_xml(self, xml, auth={}, cfdi='', info={'tipo': 'cfdi3.3'}): + def cancel_xml(self, xml, auth={}, cfdi='', info={'tipo': 'cfdi'}): if DEBUG or not auth: auth = AUTH diff --git a/source/app/controllers/utils.py b/source/app/controllers/utils.py index 28e731e..26cccc1 100644 --- a/source/app/controllers/utils.py +++ b/source/app/controllers/utils.py @@ -722,14 +722,10 @@ def xml_cancel(xml, auth, cert, name): def get_client_balance(auth, rfc=''): - if DEBUG: - return '-d' - pac = PACS[auth['pac']]() balance = pac.client_balance(auth, rfc) if pac.error: balance = 'p/e' - return balance diff --git a/source/app/models/main.py b/source/app/models/main.py index 8074856..3c5c2fb 100644 --- a/source/app/models/main.py +++ b/source/app/models/main.py @@ -4897,11 +4897,12 @@ class Facturas(BaseModel): files = (cls.get_pdf(id, rfc), cls.get_xml(id)) fields = util.make_fields(obj.xml) + starttls = bool(int(values.get('correo_starttls', '0'))) server = { 'servidor': values['correo_servidor'], 'puerto': values['correo_puerto'], 'ssl': bool(int(values['correo_ssl'])), - 'starttls': bool(int(values['correo_starttls'])), + 'starttls': starttls, 'usuario': values['correo_usuario'], 'contra': utils.decrypt(contra, rfc), } @@ -6335,10 +6336,12 @@ class PreFacturas(BaseModel): rfc = Emisor.select()[0].rfc asunto = 'Enviamos la prefactura: PRE-{}'.format(obj.folio) + starttls = bool(int(values.get('correo_starttls', '0'))) server = { 'servidor': values['correo_servidor'], 'puerto': values['correo_puerto'], 'ssl': bool(int(values['correo_ssl'])), + 'starttls': starttls, 'usuario': values['correo_usuario'], 'contra': utils.decrypt(contra, rfc), } diff --git a/source/app/settings.py b/source/app/settings.py index 4ca5055..89a6391 100644 --- a/source/app/settings.py +++ b/source/app/settings.py @@ -42,7 +42,7 @@ except ImportError: DEBUG = DEBUG -VERSION = '1.45.0' +VERSION = '1.45.1' EMAIL_SUPPORT = ('soporte@empresalibre.mx',) TITLE_APP = '{} v{}'.format(TITLE_APP, VERSION) From e40acd28bae182e266dfb90cb7ce3d06c46d809d Mon Sep 17 00:00:00 2001 From: El Mau Date: Thu, 20 Jan 2022 17:02:11 -0600 Subject: [PATCH 2/2] Corregir el error al enviar correo --- CHANGELOG.md | 2 +- .../pacs/comerciodigital/comercio.py | 39 ++++++++++--------- source/app/controllers/utils.py | 4 +- source/app/settings.py | 4 +- 4 files changed, 26 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f5e4557..9915807 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ v 1.45.1 [20-Ene-2022] ---------------------- - Error: Al enviar correos con la nueva configuración - - Error: Al cancelar CFDI + * IMPORTANTE: Revisa tu configuración de correo para verificar que todo funcione. diff --git a/source/app/controllers/pacs/comerciodigital/comercio.py b/source/app/controllers/pacs/comerciodigital/comercio.py index 595624b..8976496 100644 --- a/source/app/controllers/pacs/comerciodigital/comercio.py +++ b/source/app/controllers/pacs/comerciodigital/comercio.py @@ -24,7 +24,8 @@ import lxml.etree as ET import requests from requests.exceptions import ConnectionError -from .conf import DEBUG, AUTH +from .conf import DEBUG +# ~ , AUTH LOG_FORMAT = '%(asctime)s - %(levelname)s - %(message)s' @@ -107,9 +108,9 @@ class PACComercioDigital(object): pretty_print=True, doctype='') return xml - def stamp(self, cfdi, auth={}): - if DEBUG or not auth: - auth = AUTH + def stamp(self, cfdi, auth): + # ~ if DEBUG or not auth: + # ~ auth = AUTH url = self.URL['timbra'] headers = { @@ -147,7 +148,7 @@ class PACComercioDigital(object): return data def _get_data_cancel(self, cfdi, info, auth): - info['pass'] = '12345678a' + info['pass'] = '' info['tipo'] = 'cfdi' info['key'] = base64.b64encode(info['key']).decode() info['cer'] = base64.b64encode(info['cer']).decode() @@ -190,9 +191,9 @@ class PACComercioDigital(object): ) return '\n'.join(data) - def cancel(self, cfdi, info, auth={}): - if DEBUG or not auth: - auth = AUTH + def cancel(self, cfdi, info, auth): + # ~ if DEBUG or not auth: + # ~ auth = AUTH url = self.URL['cancel'] data = self._get_data_cancel(cfdi, info, auth) @@ -245,9 +246,9 @@ class PACComercioDigital(object): return headers - def cancel_xml(self, xml, auth={}, cfdi='', info={'tipo': 'cfdi'}): - if DEBUG or not auth: - auth = AUTH + def cancel_xml(self, xml, auth, cfdi='', info={'tipo': 'cfdi'}): + # ~ if DEBUG or not auth: + # ~ auth = AUTH url = self.URL['cancelxml'] headers = self._get_headers_cancel_xml(cfdi, info, auth) @@ -272,9 +273,9 @@ class PACComercioDigital(object): } return data - def status(self, data, auth={}): - if not auth: - auth = AUTH + def status(self, data, auth): + # ~ if not auth: + # ~ auth = AUTH url = self.URL['status'] data = ( @@ -323,8 +324,8 @@ class PACComercioDigital(object): return '\n'.join(data) - def client_add(self, data): - auth = AUTH + def client_add(self, data, auth): + # ~ auth = AUTH url = self.URL['client'] data = self._get_data_client(auth, data) @@ -371,9 +372,9 @@ class PACComercioDigital(object): return result.text - def client_add_timbres(self, data, auth={}): - if not auth: - auth = AUTH + def client_add_timbres(self, data, auth): + # ~ if not auth: + # ~ auth = AUTH url = self.URL['timbres'] data = '\n'.join(( f"usr_ws={auth['user']}", diff --git a/source/app/controllers/utils.py b/source/app/controllers/utils.py index 26cccc1..6886885 100644 --- a/source/app/controllers/utils.py +++ b/source/app/controllers/utils.py @@ -779,7 +779,8 @@ def _cancel_with_cert(invoice, args, auth, certificado): def cancel_xml_sign(invoice, args, auth, certificado): - if DEBUG: + # ~ if DEBUG: + if auth['pac'] == 'finkok': return _cancel_with_cert(invoice, args, auth, certificado) cert = SATCertificate(certificado.cer, certificado.key_enc.encode()) @@ -788,6 +789,7 @@ def cancel_xml_sign(invoice, args, auth, certificado): 'rfc': certificado.rfc, 'fecha': now().isoformat()[:19], 'uuid': str(invoice.uuid).upper(), + 'motivo': args['reason'], } template = TEMPLATE_CANCEL.format(**data) tree = ET.fromstring(template.encode()) diff --git a/source/app/settings.py b/source/app/settings.py index 89a6391..811f78f 100644 --- a/source/app/settings.py +++ b/source/app/settings.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # ~ Empresa Libre -# ~ Copyright (C) 2016-2018 Mauricio Baeza Servin (web@correolibre.net) +# ~ Copyright (C) 2016-2018 Mauricio Baeza Servin (publico@cuates.net) # ~ # ~ This program is free software: you can redistribute it and/or modify # ~ it under the terms of the GNU General Public License as published by @@ -258,7 +258,7 @@ DEFAULT_GLOBAL = { TEMPLATE_CANCEL = """ - {uuid} +