Corregir error al cancelar nomina

This commit is contained in:
El Mau 2021-12-12 13:51:51 -06:00
parent db77f6972d
commit 8a151d42ad
4 changed files with 12 additions and 13 deletions

View File

@ -1,4 +1,4 @@
v 1.43.0 [05-Dic-2021] v 1.43.0 [12-Dic-2021]
---------------------- ----------------------
- Soporte para entradas de almacen. - Soporte para entradas de almacen.
- Soporte para multi almacen. - Soporte para multi almacen.

View File

@ -682,7 +682,7 @@ def _cancel_with_cert(invoice, auth, certificado):
def cancel_xml_sign(invoice, auth, certificado): def cancel_xml_sign(invoice, auth, certificado):
# ~ return _cancel_with_cert(invoice, auth, certificado) return _cancel_with_cert(invoice, 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']]()

View File

@ -42,6 +42,7 @@ from settings import log, COMPANIES, VERSION, PATH_CP, PRE, CURRENT_CFDI, \
from controllers import utils from controllers import utils
from settings import ( from settings import (
DEBUG, DEBUG,
CANCEL_VERSION,
DEFAULT_GLOBAL, DEFAULT_GLOBAL,
DB_COMPANIES, DB_COMPANIES,
EXT, EXT,
@ -4318,8 +4319,8 @@ class Facturas(BaseModel):
@classmethod @classmethod
def _cancel_xml_sign(cls, invoice): def _cancel_xml_sign(cls, invoice):
if invoice.version != '3.3': if not invoice.version in CANCEL_VERSION:
msg = 'Solo es posible cancelar CFDI 3.3' msg = 'Solo es posible cancelar CFDI >= 3.3'
return {'ok': False, 'msg': msg} return {'ok': False, 'msg': msg}
pac = utils.get_pac_by_rfc(invoice.xml) pac = utils.get_pac_by_rfc(invoice.xml)
@ -4361,8 +4362,8 @@ class Facturas(BaseModel):
obj.estatus = 'Cancelada' obj.estatus = 'Cancelada'
obj.error = '' obj.error = ''
obj.cancelada = True obj.cancelada = True
obj.fecha_cancelacion = result['Fecha'] obj.fecha_cancelacion = result['date']
obj.acuse = result['Acuse'] or '' obj.acuse = result['acuse'] or ''
self._actualizar_saldo_cliente(self, obj, True) self._actualizar_saldo_cliente(self, obj, True)
self._update_inventory(self, obj, True) self._update_inventory(self, obj, True)
self._uncancel_tickets(self, obj) self._uncancel_tickets(self, obj)
@ -7026,10 +7027,6 @@ class CfdiPagos(BaseModel):
data = {'ok': False, 'msg': msg} data = {'ok': False, 'msg': msg}
return data return data
# ~ auth = Configuracion.get_({'fields': 'pac_auth'})
# ~ certificado = Certificado.get(Certificado.es_fiel==False)
# ~ result = utils.cancel_xml_sign(last, auth, certificado)
pac = utils.get_pac_by_rfc(last.xml) pac = utils.get_pac_by_rfc(last.xml)
auth = Configuracion.get_({'fields': 'auth_by_pac', 'pac': pac}) auth = Configuracion.get_({'fields': 'auth_by_pac', 'pac': pac})
@ -7040,7 +7037,7 @@ class CfdiPagos(BaseModel):
last.estatus = 'Cancelada' last.estatus = 'Cancelada'
last.error = '' last.error = ''
last.cancelada = True last.cancelada = True
last.fecha_cancelacion = result['Fecha'] last.fecha_cancelacion = result['date']
else: else:
last.error = result['msg'] last.error = result['msg']
last.save() last.save()
@ -8648,8 +8645,8 @@ class CfdiNomina(BaseModel):
obj.estatus = 'Cancelado' obj.estatus = 'Cancelado'
obj.error = '' obj.error = ''
obj.cancelada = True obj.cancelada = True
obj.fecha_cancelacion = result['Fecha'] obj.fecha_cancelacion = result['date']
obj.acuse = result['Acuse'] or '' obj.acuse = result['acuse'] or ''
else: else:
obj.error = result['msg'] obj.error = result['msg']
obj.save() obj.save()

View File

@ -192,6 +192,8 @@ API = 'https://api.empresalibre.net{}'
CURRENCY_MN = 'MXN' CURRENCY_MN = 'MXN'
# ~ v2 # ~ v2
CANCEL_VERSION = ('3.3', '4.0')
IS_MV = MV IS_MV = MV
DB_COMPANIES = os.path.abspath(os.path.join(BASE_DIR, '..', 'db', 'rfc.db')) DB_COMPANIES = os.path.abspath(os.path.join(BASE_DIR, '..', 'db', 'rfc.db'))
path_bk = os.path.join(path_docs, 'tmp') path_bk = os.path.join(path_docs, 'tmp')