forked from elmau/empresa-libre
Fix - Issue #40
This commit is contained in:
commit
cc0eee1443
|
@ -1,3 +1,8 @@
|
||||||
|
v 1.45.3 [23-Ene-2022]
|
||||||
|
----------------------
|
||||||
|
- Error: El enviar por correo CFDI de pago. Ticket #40
|
||||||
|
|
||||||
|
|
||||||
v 1.45.2 [21-Ene-2022]
|
v 1.45.2 [21-Ene-2022]
|
||||||
----------------------
|
----------------------
|
||||||
- Error: Al cancelar un CFDI
|
- Error: Al cancelar un CFDI
|
||||||
|
|
|
@ -28,6 +28,18 @@ class SATCertificate(object):
|
||||||
self._init_values()
|
self._init_values()
|
||||||
self._get_data_cer(cer)
|
self._get_data_cer(cer)
|
||||||
self._get_data_key(key, password)
|
self._get_data_key(key, password)
|
||||||
|
if not password:
|
||||||
|
self._test()
|
||||||
|
|
||||||
|
def _test(self):
|
||||||
|
key = self._get_key('')
|
||||||
|
self._p = TOKEN
|
||||||
|
self._key_der = key.private_bytes(
|
||||||
|
encoding=serialization.Encoding.DER,
|
||||||
|
format=serialization.PrivateFormat.PKCS8,
|
||||||
|
encryption_algorithm=serialization.BestAvailableEncryption(self._p.encode())
|
||||||
|
)
|
||||||
|
return
|
||||||
|
|
||||||
def _init_values(self):
|
def _init_values(self):
|
||||||
self._rfc = ''
|
self._rfc = ''
|
||||||
|
@ -44,6 +56,7 @@ class SATCertificate(object):
|
||||||
self._cer_pem = ''
|
self._cer_pem = ''
|
||||||
self._cer_txt = ''
|
self._cer_txt = ''
|
||||||
self._key_enc = b''
|
self._key_enc = b''
|
||||||
|
self._key_der = b''
|
||||||
self._p12 = b''
|
self._p12 = b''
|
||||||
self._cer_modulus = 0
|
self._cer_modulus = 0
|
||||||
self._key_modulus = 0
|
self._key_modulus = 0
|
||||||
|
@ -168,6 +181,8 @@ class SATCertificate(object):
|
||||||
node.text = self.serial_number
|
node.text = self.serial_number
|
||||||
# ~ node = xmlsec.tree.find_node(tree, 'SignatureValue')
|
# ~ node = xmlsec.tree.find_node(tree, 'SignatureValue')
|
||||||
# ~ node.text = node.text.replace('\n', '')
|
# ~ node.text = node.text.replace('\n', '')
|
||||||
|
# ~ node = xmlsec.tree.find_node(tree, 'Modulus')
|
||||||
|
# ~ node.text = node.text.replace('\n', '')
|
||||||
|
|
||||||
xml_signed = ET.tostring(tree,
|
xml_signed = ET.tostring(tree,
|
||||||
xml_declaration=True, encoding='UTF-8').decode()
|
xml_declaration=True, encoding='UTF-8').decode()
|
||||||
|
|
|
@ -148,9 +148,8 @@ 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'] = ''
|
|
||||||
info['tipo'] = 'cfdi'
|
info['tipo'] = 'cfdi'
|
||||||
info['key'] = base64.b64encode(info['key']).decode()
|
info['key'] = base64.b64encode(info['key_enc']).decode()
|
||||||
info['cer'] = base64.b64encode(info['cer']).decode()
|
info['cer'] = base64.b64encode(info['cer']).decode()
|
||||||
|
|
||||||
NS_CFDI = {
|
NS_CFDI = {
|
||||||
|
|
|
@ -765,7 +765,9 @@ def get_pac_by_rfc(cfdi):
|
||||||
def _cancel_with_cert(invoice, args, auth, certificado):
|
def _cancel_with_cert(invoice, args, auth, certificado):
|
||||||
cert = SATCertificate(certificado.cer, certificado.key_enc.encode())
|
cert = SATCertificate(certificado.cer, certificado.key_enc.encode())
|
||||||
pac = PACS[auth['pac']]()
|
pac = PACS[auth['pac']]()
|
||||||
info = {'cer': cert.cer_pem, 'key': cert.key_pem, 'args': args}
|
info = {'cer': cert.cer_pem, 'key': cert.key_pem, 'pass': '', 'args': args}
|
||||||
|
# ~ info = {'cer': cert.cer_pem, 'key': cert.key_pem,
|
||||||
|
# ~ 'key_enc': cert._key_der, 'pass': cert._p, 'args': args}
|
||||||
|
|
||||||
result = pac.cancel(invoice.xml, info, auth)
|
result = pac.cancel(invoice.xml, info, auth)
|
||||||
if pac.error:
|
if pac.error:
|
||||||
|
@ -779,7 +781,6 @@ 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 auth['pac'] == 'finkok':
|
if auth['pac'] == 'finkok':
|
||||||
return _cancel_with_cert(invoice, args, auth, certificado)
|
return _cancel_with_cert(invoice, args, auth, certificado)
|
||||||
|
|
||||||
|
@ -798,6 +799,7 @@ def cancel_xml_sign(invoice, args, 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)
|
||||||
|
# ~ print(sign_xml)
|
||||||
|
|
||||||
result = pac.cancel_xml(sign_xml, auth, invoice.xml)
|
result = pac.cancel_xml(sign_xml, auth, invoice.xml)
|
||||||
|
|
||||||
|
|
|
@ -4518,6 +4518,7 @@ class Facturas(BaseModel):
|
||||||
(True, 'Si'),
|
(True, 'Si'),
|
||||||
(False, 'No'),
|
(False, 'No'),
|
||||||
)).alias('paid'),
|
)).alias('paid'),
|
||||||
|
Facturas.metodo_pago,
|
||||||
Facturas.total,
|
Facturas.total,
|
||||||
Facturas.moneda.alias('currency'),
|
Facturas.moneda.alias('currency'),
|
||||||
Facturas.total_mn,
|
Facturas.total_mn,
|
||||||
|
@ -7635,10 +7636,12 @@ class CfdiPagos(BaseModel):
|
||||||
files = (self.get_file_pdf(id), self.get_file_xml(id))
|
files = (self.get_file_pdf(id), self.get_file_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': starttls,
|
||||||
'usuario': values['correo_usuario'],
|
'usuario': values['correo_usuario'],
|
||||||
'contra': utils.decrypt(contra, rfc),
|
'contra': utils.decrypt(contra, rfc),
|
||||||
}
|
}
|
||||||
|
@ -8887,10 +8890,12 @@ class CfdiNomina(BaseModel):
|
||||||
)
|
)
|
||||||
|
|
||||||
message = subject = f"Enviamos tu recibo de nómina"
|
message = subject = f"Enviamos tu recibo de nómina"
|
||||||
|
starttls = bool(int(values.get('correo_starttls', '0')))
|
||||||
server = {
|
server = {
|
||||||
'server': config['correo_servidor'],
|
'server': config['correo_servidor'],
|
||||||
'port': config['correo_puerto'],
|
'port': config['correo_puerto'],
|
||||||
'ssl': utils.to_bool(config['correo_ssl']),
|
'ssl': utils.to_bool(config['correo_ssl']),
|
||||||
|
'starttls': starttls,
|
||||||
'user': config['correo_usuario'],
|
'user': config['correo_usuario'],
|
||||||
'pass': utils.decrypt(contra, emisor.rfc),
|
'pass': utils.decrypt(contra, emisor.rfc),
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ except ImportError:
|
||||||
|
|
||||||
|
|
||||||
DEBUG = DEBUG
|
DEBUG = DEBUG
|
||||||
VERSION = '1.45.2'
|
VERSION = '1.45.3'
|
||||||
EMAIL_SUPPORT = ('soporte@empresalibre.mx',)
|
EMAIL_SUPPORT = ('soporte@empresalibre.mx',)
|
||||||
TITLE_APP = '{} v{}'.format(TITLE_APP, VERSION)
|
TITLE_APP = '{} v{}'.format(TITLE_APP, VERSION)
|
||||||
|
|
||||||
|
@ -290,3 +290,4 @@ TEMPLATE_CANCEL = """<Cancelacion xmlns="http://cancelacfd.sat.gob.mx" xmlns:xsd
|
||||||
</KeyInfo>
|
</KeyInfo>
|
||||||
</Signature>
|
</Signature>
|
||||||
</Cancelacion>"""
|
</Cancelacion>"""
|
||||||
|
# ~ 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><Folio UUID="{uuid}" Motivo="{motivo}"{folio}/></Folios><Signature xmlns="http://www.w3.org/2000/09/xmldsig#"><SignedInfo><CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315" /><SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" /><Reference URI=""><Transforms><Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" /></Transforms><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" /><DigestValue/></Reference></SignedInfo><SignatureValue/><KeyInfo><X509Data><X509IssuerSerial><X509IssuerName/><X509SerialNumber/></X509IssuerSerial><X509Certificate/></X509Data><KeyValue><RSAKeyValue><Modulus/><Exponent/></RSAKeyValue></KeyValue></KeyInfo></Signature></Cancelacion>"""
|
||||||
|
|
|
@ -258,6 +258,8 @@ var grid_invoices_cols = [
|
||||||
adjust: "data", sort:"string"},
|
adjust: "data", sort:"string"},
|
||||||
{id: "paid", header: ["Pagada", {content: "selectFilter"}],
|
{id: "paid", header: ["Pagada", {content: "selectFilter"}],
|
||||||
adjust: "data", sort:"string"},
|
adjust: "data", sort:"string"},
|
||||||
|
{id: 'metodo_pago', header: ['Método de Pago', {content: 'selectFilter'}],
|
||||||
|
adjust: 'data', hidden: true},
|
||||||
{id: 'total', header: ['Total', {content: 'numberFilter'}],
|
{id: 'total', header: ['Total', {content: 'numberFilter'}],
|
||||||
width: 125, sort: 'int', format: webix.i18n.priceFormat, css: 'right',
|
width: 125, sort: 'int', format: webix.i18n.priceFormat, css: 'right',
|
||||||
hidden: true},
|
hidden: true},
|
||||||
|
|
Loading…
Reference in New Issue