From b2cdd0efbec5135601dccb5bb91d5d38e7deb15a Mon Sep 17 00:00:00 2001 From: El Mau Date: Tue, 15 Feb 2022 23:50:02 -0600 Subject: [PATCH] Fix - Issue #53 --- CHANGELOG.md | 5 ++ VERSION | 2 +- source/app/models/main.py | 3 +- source/app/settings.py | 2 +- source/static/js/controller/bancos.js | 112 +++++++++++++++++++------- source/static/js/ui/bancos.js | 42 ++++++++++ 6 files changed, 136 insertions(+), 30 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index caba239..0b4b449 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +v 1.46.3 [15-Feb-2022] +---------------------- + - Error: Issue #53 + + v 1.46.2 [31-Ene-2022] ---------------------- - Error: Al generar Carta Porte sin remolque. diff --git a/VERSION b/VERSION index 0c0f059..c9e1991 100644 --- a/VERSION +++ b/VERSION @@ -1,2 +1,2 @@ -1.46.2 +1.46.3 diff --git a/source/app/models/main.py b/source/app/models/main.py index c0d2d99..32122eb 100644 --- a/source/app/models/main.py +++ b/source/app/models/main.py @@ -7168,6 +7168,7 @@ class CfdiPagos(BaseModel): def _cancel(self, values): id_mov = int(values['id_mov']) + args = utils.loads(values['args']) filters = ( (CfdiPagos.movimiento==id_mov) & @@ -7194,7 +7195,7 @@ class CfdiPagos(BaseModel): auth = Configuracion.get_({'fields': 'auth_by_pac', 'pac': pac}) certificado = Certificado.get(Certificado.es_fiel==False) - result = utils.cancel_xml_sign(last, auth, certificado) + result = utils.cancel_xml_sign(last, args, auth, certificado) if result['ok']: last.estatus = 'Cancelada' diff --git a/source/app/settings.py b/source/app/settings.py index d473d2d..da296ee 100644 --- a/source/app/settings.py +++ b/source/app/settings.py @@ -42,7 +42,7 @@ except ImportError: DEBUG = DEBUG -VERSION = '1.46.2' +VERSION = '1.46.3' EMAIL_SUPPORT = ('soporte@empresalibre.mx',) TITLE_APP = '{} v{}'.format(TITLE_APP, VERSION) diff --git a/source/static/js/controller/bancos.js b/source/static/js/controller/bancos.js index d28181c..7831b85 100644 --- a/source/static/js/controller/bancos.js +++ b/source/static/js/controller/bancos.js @@ -1063,6 +1063,61 @@ function cmd_pay_stamp_click(){ } +function cmd_win_cancel_pay_close_click(){ + $$('win_invoice_cancel_pay').close() +} + + +function send_invoice_cancel_pay(reason='', uuid=''){ + var grid = $$('grid_cfdi_pay') + var form = $$('form_bank_pay') + var values = form.getValues() + var data = { + 'opt': 'cancel', + 'id_mov': values.id_mov, + args: { + reason: reason, + uuid: uuid, + } + } + + webix.ajax().post('cfdipay', data, function(text, data){ + var values = data.json() + if(values.ok){ + msg_ok(values.msg) + grid.updateItem(values.id, {'estatus': 'Cancelada'}) + }else{ + msg_error('No fue posible cancelar') + webix.alert({ + title: 'Error al Cancelar', + text: values.msg, + type: 'alert-error' + }) + } + }) +} + + +function cmd_invoice_cancel_pay_click(){ + var reason = $$('lst_reasons_cancel').getValue() + var uuid = $$('txt_cancel_uuid').getValue() + + if(!reason){ + msg = 'Selecciona un motivo para esta cancelación' + msg_error(msg) + return + } + if(reason=='01' & !uuid){ + msg = 'Debes de capturar el UUID que reemplaza a este CFDI' + msg_error(msg) + return + } + + send_invoice_cancel_pay(reason, uuid) + $$('win_invoice_cancel_pay').close() +} + + function cmd_pay_cancel_click(){ var form = $$('form_bank_pay') var values = form.getValues() @@ -1074,33 +1129,36 @@ function cmd_pay_cancel_click(){ return } - msg = '¿Estás seguro de cancelar esta factura?\n\nESTA ACCIÓN NO SE PUEDE DESHACER' - webix.confirm({ - title: 'Cancelar Factura', - ok: 'Si', - cancel: 'No', - type: 'confirm-error', - text: msg, - callback:function(result){ - if(result){ - webix.ajax().post('/cfdipay', data, { - error:function(text, data, XmlHttpRequest){ - msg = 'Ocurrio un error, consulta a soporte técnico' - msg_error(msg) - }, - success:function(text, data, XmlHttpRequest){ - values = data.json(); - if(values.ok){ - grid.updateItem(values.id, {'estatus': 'Cancelada'}) - msg_ok(values.msg) - }else{ - msg_error(values.msg) - } - } - }) - } - } - }) + win_invoice_cancel_pay.init() + $$('win_invoice_cancel_pay').show() + + //~ msg = '¿Estás seguro de cancelar esta factura?\n\nESTA ACCIÓN NO SE PUEDE DESHACER' + //~ webix.confirm({ + //~ title: 'Cancelar Factura', + //~ ok: 'Si', + //~ cancel: 'No', + //~ type: 'confirm-error', + //~ text: msg, + //~ callback:function(result){ + //~ if(result){ + //~ webix.ajax().post('/cfdipay', data, { + //~ error:function(text, data, XmlHttpRequest){ + //~ msg = 'Ocurrio un error, consulta a soporte técnico' + //~ msg_error(msg) + //~ }, + //~ success:function(text, data, XmlHttpRequest){ + //~ values = data.json(); + //~ if(values.ok){ + //~ grid.updateItem(values.id, {'estatus': 'Cancelada'}) + //~ msg_ok(values.msg) + //~ }else{ + //~ msg_error(values.msg) + //~ } + //~ } + //~ }) + //~ } + //~ } + //~ }) } diff --git a/source/static/js/ui/bancos.js b/source/static/js/ui/bancos.js index 35a7491..459d9a8 100644 --- a/source/static/js/ui/bancos.js +++ b/source/static/js/ui/bancos.js @@ -608,3 +608,45 @@ var win_mov_description = { $$('cmd_close_mov_description').attachEvent('onItemClick', cmd_close_mov_description_click) } } + + + +var opt_reasons_cancel_pay = [ + {id: '', value: ''}, + {id: '01', value: '[01] Comprobante emitido con errores con relación'}, + {id: '02', value: '[02] Comprobante emitido con errores sin relación'}, + {id: '03', value: '[03] No se llevó acabo la operación'}, + {id: '04', value: '[04] Operación nominativa relacionada en una factura global'}, +] + + +var body_invoice_cancel_pay = {rows: [{minHeight: 15}, + {view: 'richselect', id: 'lst_reasons_cancel', labelPosition: 'top', label: 'Razón de cancelación', options: opt_reasons_cancel_pay, value: '', width: 400}, + {view: 'text', id: 'txt_cancel_uuid', labelPosition: 'top', label: 'UUID que sustituye', width: 400}, + {view: 'label', label: 'Esta acción no se puede deshacer', autowidth: true, align: 'center'}, + {view: 'label', label: '¿Estás segura de continuar?', autowidth: true, align: 'center'}, + {cols: [{}, + {view: 'button', id: 'cmd_invoice_cancel_pay', width: 100, label: 'Cancelar', type: 'danger', icon: 'ban'}, + {maxWidth: 25}, + {view: 'button', id: 'cmd_win_cancel_pay_close', width: 100, label: 'Cerrar'}, + {} + ]}, + {minHeight: 20}, +]} + + +var win_invoice_cancel_pay = { + init: function(){ + webix.ui({ + view: 'window', + id: 'win_invoice_cancel_pay', + modal: true, + width: 400, + position: 'center', + head: 'Cancelar CFDI', + body: body_invoice_cancel_pay, + }) + $$('cmd_invoice_cancel_pay').attachEvent('onItemClick', cmd_invoice_cancel_pay_click) + $$('cmd_win_cancel_pay_close').attachEvent('onItemClick', cmd_win_cancel_pay_close_click) + } +}