forked from elmau/empresa-libre
Corregir error al enviar correo
This commit is contained in:
commit
9daf07693a
|
@ -1,3 +1,11 @@
|
||||||
|
v 1.45.1 [20-Ene-2022]
|
||||||
|
----------------------
|
||||||
|
- Error: Al enviar correos con la nueva configuración
|
||||||
|
|
||||||
|
|
||||||
|
* IMPORTANTE: Revisa tu configuración de correo para verificar que todo funcione.
|
||||||
|
|
||||||
|
|
||||||
v 1.45.0 [20-Ene-2022]
|
v 1.45.0 [20-Ene-2022]
|
||||||
----------------------
|
----------------------
|
||||||
- Importar Carta Porte desde archivo JSON
|
- Importar Carta Porte desde archivo JSON
|
||||||
|
|
|
@ -24,7 +24,8 @@ import lxml.etree as ET
|
||||||
import requests
|
import requests
|
||||||
from requests.exceptions import ConnectionError
|
from requests.exceptions import ConnectionError
|
||||||
|
|
||||||
from .conf import DEBUG, AUTH
|
from .conf import DEBUG
|
||||||
|
# ~ , AUTH
|
||||||
|
|
||||||
|
|
||||||
LOG_FORMAT = '%(asctime)s - %(levelname)s - %(message)s'
|
LOG_FORMAT = '%(asctime)s - %(levelname)s - %(message)s'
|
||||||
|
@ -107,9 +108,9 @@ class PACComercioDigital(object):
|
||||||
pretty_print=True, doctype='<?xml version="1.0" encoding="utf-8"?>')
|
pretty_print=True, doctype='<?xml version="1.0" encoding="utf-8"?>')
|
||||||
return xml
|
return xml
|
||||||
|
|
||||||
def stamp(self, cfdi, auth={}):
|
def stamp(self, cfdi, auth):
|
||||||
if DEBUG or not auth:
|
# ~ if DEBUG or not auth:
|
||||||
auth = AUTH
|
# ~ auth = AUTH
|
||||||
|
|
||||||
url = self.URL['timbra']
|
url = self.URL['timbra']
|
||||||
headers = {
|
headers = {
|
||||||
|
@ -147,7 +148,7 @@ class PACComercioDigital(object):
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def _get_data_cancel(self, cfdi, info, auth):
|
def _get_data_cancel(self, cfdi, info, auth):
|
||||||
info['pass'] = '12345678a'
|
info['pass'] = ''
|
||||||
info['tipo'] = 'cfdi'
|
info['tipo'] = 'cfdi'
|
||||||
info['key'] = base64.b64encode(info['key']).decode()
|
info['key'] = base64.b64encode(info['key']).decode()
|
||||||
info['cer'] = base64.b64encode(info['cer']).decode()
|
info['cer'] = base64.b64encode(info['cer']).decode()
|
||||||
|
@ -190,9 +191,9 @@ class PACComercioDigital(object):
|
||||||
)
|
)
|
||||||
return '\n'.join(data)
|
return '\n'.join(data)
|
||||||
|
|
||||||
def cancel(self, cfdi, info, auth={}):
|
def cancel(self, cfdi, info, auth):
|
||||||
if DEBUG or not auth:
|
# ~ if DEBUG or not auth:
|
||||||
auth = AUTH
|
# ~ auth = AUTH
|
||||||
url = self.URL['cancel']
|
url = self.URL['cancel']
|
||||||
data = self._get_data_cancel(cfdi, info, auth)
|
data = self._get_data_cancel(cfdi, info, auth)
|
||||||
|
|
||||||
|
@ -245,9 +246,9 @@ class PACComercioDigital(object):
|
||||||
|
|
||||||
return headers
|
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:
|
# ~ if DEBUG or not auth:
|
||||||
auth = AUTH
|
# ~ auth = AUTH
|
||||||
|
|
||||||
url = self.URL['cancelxml']
|
url = self.URL['cancelxml']
|
||||||
headers = self._get_headers_cancel_xml(cfdi, info, auth)
|
headers = self._get_headers_cancel_xml(cfdi, info, auth)
|
||||||
|
@ -272,9 +273,9 @@ class PACComercioDigital(object):
|
||||||
}
|
}
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def status(self, data, auth={}):
|
def status(self, data, auth):
|
||||||
if not auth:
|
# ~ if not auth:
|
||||||
auth = AUTH
|
# ~ auth = AUTH
|
||||||
url = self.URL['status']
|
url = self.URL['status']
|
||||||
|
|
||||||
data = (
|
data = (
|
||||||
|
@ -323,8 +324,8 @@ class PACComercioDigital(object):
|
||||||
|
|
||||||
return '\n'.join(data)
|
return '\n'.join(data)
|
||||||
|
|
||||||
def client_add(self, data):
|
def client_add(self, data, auth):
|
||||||
auth = AUTH
|
# ~ auth = AUTH
|
||||||
url = self.URL['client']
|
url = self.URL['client']
|
||||||
data = self._get_data_client(auth, data)
|
data = self._get_data_client(auth, data)
|
||||||
|
|
||||||
|
@ -371,9 +372,9 @@ class PACComercioDigital(object):
|
||||||
|
|
||||||
return result.text
|
return result.text
|
||||||
|
|
||||||
def client_add_timbres(self, data, auth={}):
|
def client_add_timbres(self, data, auth):
|
||||||
if not auth:
|
# ~ if not auth:
|
||||||
auth = AUTH
|
# ~ auth = AUTH
|
||||||
url = self.URL['timbres']
|
url = self.URL['timbres']
|
||||||
data = '\n'.join((
|
data = '\n'.join((
|
||||||
f"usr_ws={auth['user']}",
|
f"usr_ws={auth['user']}",
|
||||||
|
|
|
@ -722,14 +722,10 @@ def xml_cancel(xml, auth, cert, name):
|
||||||
|
|
||||||
|
|
||||||
def get_client_balance(auth, rfc=''):
|
def get_client_balance(auth, rfc=''):
|
||||||
if DEBUG:
|
|
||||||
return '-d'
|
|
||||||
|
|
||||||
pac = PACS[auth['pac']]()
|
pac = PACS[auth['pac']]()
|
||||||
balance = pac.client_balance(auth, rfc)
|
balance = pac.client_balance(auth, rfc)
|
||||||
if pac.error:
|
if pac.error:
|
||||||
balance = 'p/e'
|
balance = 'p/e'
|
||||||
|
|
||||||
return balance
|
return balance
|
||||||
|
|
||||||
|
|
||||||
|
@ -783,7 +779,8 @@ def _cancel_with_cert(invoice, args, auth, certificado):
|
||||||
|
|
||||||
|
|
||||||
def cancel_xml_sign(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)
|
return _cancel_with_cert(invoice, args, auth, certificado)
|
||||||
|
|
||||||
cert = SATCertificate(certificado.cer, certificado.key_enc.encode())
|
cert = SATCertificate(certificado.cer, certificado.key_enc.encode())
|
||||||
|
@ -792,6 +789,7 @@ def cancel_xml_sign(invoice, args, auth, certificado):
|
||||||
'rfc': certificado.rfc,
|
'rfc': certificado.rfc,
|
||||||
'fecha': now().isoformat()[:19],
|
'fecha': now().isoformat()[:19],
|
||||||
'uuid': str(invoice.uuid).upper(),
|
'uuid': str(invoice.uuid).upper(),
|
||||||
|
'motivo': args['reason'],
|
||||||
}
|
}
|
||||||
template = TEMPLATE_CANCEL.format(**data)
|
template = TEMPLATE_CANCEL.format(**data)
|
||||||
tree = ET.fromstring(template.encode())
|
tree = ET.fromstring(template.encode())
|
||||||
|
|
|
@ -4897,11 +4897,12 @@ class Facturas(BaseModel):
|
||||||
files = (cls.get_pdf(id, rfc), cls.get_xml(id))
|
files = (cls.get_pdf(id, rfc), cls.get_xml(id))
|
||||||
|
|
||||||
fields = util.make_fields(obj.xml)
|
fields = util.make_fields(obj.xml)
|
||||||
|
starttls = bool(int(values.get('correo_starttls', '0')))
|
||||||
server = {
|
server = {
|
||||||
'servidor': values['correo_servidor'],
|
'servidor': values['correo_servidor'],
|
||||||
'puerto': values['correo_puerto'],
|
'puerto': values['correo_puerto'],
|
||||||
'ssl': bool(int(values['correo_ssl'])),
|
'ssl': bool(int(values['correo_ssl'])),
|
||||||
'starttls': bool(int(values['correo_starttls'])),
|
'starttls': starttls,
|
||||||
'usuario': values['correo_usuario'],
|
'usuario': values['correo_usuario'],
|
||||||
'contra': utils.decrypt(contra, rfc),
|
'contra': utils.decrypt(contra, rfc),
|
||||||
}
|
}
|
||||||
|
@ -6335,10 +6336,12 @@ class PreFacturas(BaseModel):
|
||||||
rfc = Emisor.select()[0].rfc
|
rfc = Emisor.select()[0].rfc
|
||||||
|
|
||||||
asunto = 'Enviamos la prefactura: PRE-{}'.format(obj.folio)
|
asunto = 'Enviamos la prefactura: PRE-{}'.format(obj.folio)
|
||||||
|
starttls = bool(int(values.get('correo_starttls', '0')))
|
||||||
server = {
|
server = {
|
||||||
'servidor': values['correo_servidor'],
|
'servidor': values['correo_servidor'],
|
||||||
'puerto': values['correo_puerto'],
|
'puerto': values['correo_puerto'],
|
||||||
'ssl': bool(int(values['correo_ssl'])),
|
'ssl': bool(int(values['correo_ssl'])),
|
||||||
|
'starttls': starttls,
|
||||||
'usuario': values['correo_usuario'],
|
'usuario': values['correo_usuario'],
|
||||||
'contra': utils.decrypt(contra, rfc),
|
'contra': utils.decrypt(contra, rfc),
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
# ~ Empresa Libre
|
# ~ 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
|
# ~ 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
|
# ~ it under the terms of the GNU General Public License as published by
|
||||||
|
@ -42,7 +42,7 @@ except ImportError:
|
||||||
|
|
||||||
|
|
||||||
DEBUG = DEBUG
|
DEBUG = DEBUG
|
||||||
VERSION = '1.45.0'
|
VERSION = '1.45.1'
|
||||||
EMAIL_SUPPORT = ('soporte@empresalibre.mx',)
|
EMAIL_SUPPORT = ('soporte@empresalibre.mx',)
|
||||||
TITLE_APP = '{} v{}'.format(TITLE_APP, VERSION)
|
TITLE_APP = '{} v{}'.format(TITLE_APP, VERSION)
|
||||||
|
|
||||||
|
@ -258,7 +258,7 @@ DEFAULT_GLOBAL = {
|
||||||
|
|
||||||
TEMPLATE_CANCEL = """<Cancelacion xmlns="http://cancelacfd.sat.gob.mx" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" RfcEmisor="{rfc}" Fecha="{fecha}">
|
TEMPLATE_CANCEL = """<Cancelacion xmlns="http://cancelacfd.sat.gob.mx" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" RfcEmisor="{rfc}" Fecha="{fecha}">
|
||||||
<Folios>
|
<Folios>
|
||||||
<UUID>{uuid}</UUID>
|
<Folio UUID={uuid} Motivo={motivo}/>
|
||||||
</Folios>
|
</Folios>
|
||||||
<Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
|
<Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
|
||||||
<SignedInfo>
|
<SignedInfo>
|
||||||
|
|
Loading…
Reference in New Issue