Fix - Issue #40

This commit is contained in:
El Mau 2022-01-23 23:11:08 -06:00
commit cc0eee1443
8 changed files with 35 additions and 6 deletions

View File

@ -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]
----------------------
- Error: Al cancelar un CFDI

View File

@ -1,2 +1,2 @@
1.45.2
1.45.3

View File

@ -28,6 +28,18 @@ class SATCertificate(object):
self._init_values()
self._get_data_cer(cer)
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):
self._rfc = ''
@ -44,6 +56,7 @@ class SATCertificate(object):
self._cer_pem = ''
self._cer_txt = ''
self._key_enc = b''
self._key_der = b''
self._p12 = b''
self._cer_modulus = 0
self._key_modulus = 0
@ -168,6 +181,8 @@ class SATCertificate(object):
node.text = self.serial_number
# ~ node = xmlsec.tree.find_node(tree, 'SignatureValue')
# ~ 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_declaration=True, encoding='UTF-8').decode()

View File

@ -148,9 +148,8 @@ class PACComercioDigital(object):
return data
def _get_data_cancel(self, cfdi, info, auth):
info['pass'] = ''
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()
NS_CFDI = {

View File

@ -765,7 +765,9 @@ def get_pac_by_rfc(cfdi):
def _cancel_with_cert(invoice, args, auth, certificado):
cert = SATCertificate(certificado.cer, certificado.key_enc.encode())
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)
if pac.error:
@ -779,7 +781,6 @@ def _cancel_with_cert(invoice, args, auth, certificado):
def cancel_xml_sign(invoice, args, auth, certificado):
# ~ if DEBUG:
if auth['pac'] == 'finkok':
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)
tree = ET.fromstring(template.encode())
sign_xml = cert.sign_xml(tree)
# ~ print(sign_xml)
result = pac.cancel_xml(sign_xml, auth, invoice.xml)

View File

@ -4518,6 +4518,7 @@ class Facturas(BaseModel):
(True, 'Si'),
(False, 'No'),
)).alias('paid'),
Facturas.metodo_pago,
Facturas.total,
Facturas.moneda.alias('currency'),
Facturas.total_mn,
@ -7635,10 +7636,12 @@ class CfdiPagos(BaseModel):
files = (self.get_file_pdf(id), self.get_file_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': starttls,
'usuario': values['correo_usuario'],
'contra': utils.decrypt(contra, rfc),
}
@ -8887,10 +8890,12 @@ class CfdiNomina(BaseModel):
)
message = subject = f"Enviamos tu recibo de nómina"
starttls = bool(int(values.get('correo_starttls', '0')))
server = {
'server': config['correo_servidor'],
'port': config['correo_puerto'],
'ssl': utils.to_bool(config['correo_ssl']),
'starttls': starttls,
'user': config['correo_usuario'],
'pass': utils.decrypt(contra, emisor.rfc),
}

View File

@ -42,7 +42,7 @@ except ImportError:
DEBUG = DEBUG
VERSION = '1.45.2'
VERSION = '1.45.3'
EMAIL_SUPPORT = ('soporte@empresalibre.mx',)
TITLE_APP = '{} v{}'.format(TITLE_APP, VERSION)
@ -290,3 +290,4 @@ TEMPLATE_CANCEL = """<Cancelacion xmlns="http://cancelacfd.sat.gob.mx" xmlns:xsd
</KeyInfo>
</Signature>
</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>"""

View File

@ -258,6 +258,8 @@ var grid_invoices_cols = [
adjust: "data", sort:"string"},
{id: "paid", header: ["Pagada", {content: "selectFilter"}],
adjust: "data", sort:"string"},
{id: 'metodo_pago', header: ['Método de Pago', {content: 'selectFilter'}],
adjust: 'data', hidden: true},
{id: 'total', header: ['Total', {content: 'numberFilter'}],
width: 125, sort: 'int', format: webix.i18n.priceFormat, css: 'right',
hidden: true},