forked from elmau/empresa-libre
Add cancel invoice pay in admin list
This commit is contained in:
commit
e72739a5fe
|
@ -7447,6 +7447,33 @@ class CfdiPagos(BaseModel):
|
||||||
|
|
||||||
return {'ok': result['ok'], 'msg': result['msg'], 'id': last.id}
|
return {'ok': result['ok'], 'msg': result['msg'], 'id': last.id}
|
||||||
|
|
||||||
|
def _cancel2(self, values):
|
||||||
|
args = utils.loads(values['args'])
|
||||||
|
id = args.pop('id')
|
||||||
|
obj = CfdiPagos.get(CfdiPagos.id==id)
|
||||||
|
|
||||||
|
if not obj.uuid:
|
||||||
|
msg = 'La Factura de Pago no esta timbrada'
|
||||||
|
data = {'ok': False, 'msg': msg}
|
||||||
|
return data
|
||||||
|
|
||||||
|
pac = utils.get_pac_by_rfc(obj.xml)
|
||||||
|
auth = Configuracion.get_({'fields': 'auth_by_pac', 'pac': pac})
|
||||||
|
certificado = Certificado.get(Certificado.es_fiel==False)
|
||||||
|
|
||||||
|
result = utils.cancel_xml_sign(obj, args, auth, certificado)
|
||||||
|
|
||||||
|
if result['ok']:
|
||||||
|
obj.estatus = 'Cancelada'
|
||||||
|
obj.error = ''
|
||||||
|
obj.cancelada = True
|
||||||
|
obj.fecha_cancelacion = result['date']
|
||||||
|
else:
|
||||||
|
obj.error = result['msg']
|
||||||
|
obj.save()
|
||||||
|
|
||||||
|
return {'ok': result['ok'], 'msg': result['msg']}
|
||||||
|
|
||||||
def _get_folio(self, serie):
|
def _get_folio(self, serie):
|
||||||
folio = int(Configuracion.get_('txt_config_cfdipay_folio') or '0')
|
folio = int(Configuracion.get_('txt_config_cfdipay_folio') or '0')
|
||||||
start = (CfdiPagos
|
start = (CfdiPagos
|
||||||
|
|
|
@ -81,6 +81,7 @@ var bancos_controllers = {
|
||||||
$$('grid_bank_invoice_pay').attachEvent('onItemClick', grid_bank_invoice_pay_click)
|
$$('grid_bank_invoice_pay').attachEvent('onItemClick', grid_bank_invoice_pay_click)
|
||||||
$$('grid_cuentabanco').attachEvent('onItemDblClick', grid_cuentabanco_double_click)
|
$$('grid_cuentabanco').attachEvent('onItemDblClick', grid_cuentabanco_double_click)
|
||||||
$$('cmd_invoice_pay_sat').attachEvent('onItemClick', cmd_invoice_pay_sat_click)
|
$$('cmd_invoice_pay_sat').attachEvent('onItemClick', cmd_invoice_pay_sat_click)
|
||||||
|
$$('cmd_invoice_pay_cancel').attachEvent('onItemClick', cmd_invoice_pay_cancel_click)
|
||||||
|
|
||||||
init_config_bank()
|
init_config_bank()
|
||||||
}
|
}
|
||||||
|
@ -1426,3 +1427,83 @@ function cmd_invoice_pay_sat_click(){
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function cmd_invoice_pay_cancel_click(){
|
||||||
|
var g = $$('grid_bank_invoice_pay')
|
||||||
|
|
||||||
|
if(g.count() == 0){
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var row = g.getSelectedItem()
|
||||||
|
if (row == undefined){
|
||||||
|
msg_error('Selecciona una factura de pago')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (row instanceof Array){
|
||||||
|
msg_error('Selecciona solo una factura de pago')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!row.uuid){
|
||||||
|
msg_error('La factura de pago no esta timbrada')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
win_invoice_cancel_pay2.init()
|
||||||
|
$$('win_invoice_cancel_pay2').show()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function cmd_invoice_cancel_pay2_click(){
|
||||||
|
var reason = $$('lst_reasons_cancel2').getValue()
|
||||||
|
var uuid = $$('txt_cancel_uuid2').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_pay2(reason, uuid)
|
||||||
|
$$('win_invoice_cancel_pay2').close()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function cmd_win_cancel_pay_close2_click(){
|
||||||
|
$$('win_invoice_cancel_pay2').close()
|
||||||
|
}
|
||||||
|
|
||||||
|
function send_invoice_cancel_pay2(reason='', uuid=''){
|
||||||
|
var grid = $$('grid_bank_invoice_pay')
|
||||||
|
var row = grid.getSelectedItem()
|
||||||
|
var data = {
|
||||||
|
'opt': 'cancel2',
|
||||||
|
args: {
|
||||||
|
id: row.id,
|
||||||
|
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(row.id, {'estatus': 'Cancelada'})
|
||||||
|
}else{
|
||||||
|
msg_error('No fue posible cancelar')
|
||||||
|
webix.alert({
|
||||||
|
title: 'Error al Cancelar',
|
||||||
|
text: values.msg,
|
||||||
|
type: 'alert-error'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
@ -367,11 +367,13 @@ var toolbar_bank_invoice_pay_filter = [
|
||||||
{view: 'richselect', id: 'filter_invoice_pay_year', label: 'Año',
|
{view: 'richselect', id: 'filter_invoice_pay_year', label: 'Año',
|
||||||
labelAlign: 'right', labelWidth: 50, width: 150, options: []},
|
labelAlign: 'right', labelWidth: 50, width: 150, options: []},
|
||||||
{view: 'richselect', id: 'filter_invoice_pay_month', label: 'Mes',
|
{view: 'richselect', id: 'filter_invoice_pay_month', label: 'Mes',
|
||||||
labelAlign: 'right', labelWidth: 50, width: 200, options: months},
|
labelAlign: 'right', labelWidth: 50, width: 175, options: months},
|
||||||
{view: 'daterangepicker', id: 'filter_invoice_pay_dates', label: 'Fechas',
|
{view: 'daterangepicker', id: 'filter_invoice_pay_dates', label: 'Fechas',
|
||||||
labelAlign: 'right', width: 300},
|
labelAlign: 'right', width: 275},
|
||||||
{view: 'button', id: 'cmd_invoice_pay_sat', label: 'SAT',
|
{view: 'button', id: 'cmd_invoice_pay_sat', label: 'SAT',
|
||||||
type: 'iconButton', autowidth: true, icon: 'check-circle'},
|
type: 'iconButton', autowidth: true, icon: 'check-circle'},
|
||||||
|
{view: 'button', id: 'cmd_invoice_pay_cancel', label: 'Cancelar',
|
||||||
|
type: 'iconButton', autowidth: true, icon: 'ban'},
|
||||||
{},
|
{},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -626,7 +628,7 @@ 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: '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: '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: 'Esta acción no se puede deshacer', autowidth: true, align: 'center'},
|
||||||
{view: 'label', label: '¿Estás segura de continuar?', autowidth: true, align: 'center'},
|
{view: 'label', label: '¿Estás seguro de continuar?', autowidth: true, align: 'center'},
|
||||||
{cols: [{},
|
{cols: [{},
|
||||||
{view: 'button', id: 'cmd_invoice_cancel_pay', width: 100, label: 'Cancelar', type: 'danger', icon: 'ban'},
|
{view: 'button', id: 'cmd_invoice_cancel_pay', width: 100, label: 'Cancelar', type: 'danger', icon: 'ban'},
|
||||||
{maxWidth: 25},
|
{maxWidth: 25},
|
||||||
|
@ -652,3 +654,35 @@ var win_invoice_cancel_pay = {
|
||||||
$$('cmd_win_cancel_pay_close').attachEvent('onItemClick', cmd_win_cancel_pay_close_click)
|
$$('cmd_win_cancel_pay_close').attachEvent('onItemClick', cmd_win_cancel_pay_close_click)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var body_invoice_cancel_pay2 = {rows: [{minHeight: 15},
|
||||||
|
{view: 'richselect', id: 'lst_reasons_cancel2', labelPosition: 'top', label: 'Razón de cancelación', options: opt_reasons_cancel_pay, value: '', width: 400},
|
||||||
|
{view: 'text', id: 'txt_cancel_uuid2', 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 seguro de continuar?', autowidth: true, align: 'center'},
|
||||||
|
{cols: [{},
|
||||||
|
{view: 'button', id: 'cmd_invoice_cancel_pay2', width: 100, label: 'Cancelar', type: 'danger', icon: 'ban'},
|
||||||
|
{maxWidth: 25},
|
||||||
|
{view: 'button', id: 'cmd_win_cancel_pay_close2', width: 100, label: 'Cerrar'},
|
||||||
|
{}
|
||||||
|
]},
|
||||||
|
{minHeight: 20},
|
||||||
|
]}
|
||||||
|
|
||||||
|
|
||||||
|
var win_invoice_cancel_pay2 = {
|
||||||
|
init: function(){
|
||||||
|
webix.ui({
|
||||||
|
view: 'window',
|
||||||
|
id: 'win_invoice_cancel_pay2',
|
||||||
|
modal: true,
|
||||||
|
width: 400,
|
||||||
|
position: 'center',
|
||||||
|
head: 'Cancelar CFDI de Pago',
|
||||||
|
body: body_invoice_cancel_pay2,
|
||||||
|
})
|
||||||
|
$$('cmd_invoice_cancel_pay2').attachEvent('onItemClick', cmd_invoice_cancel_pay2_click)
|
||||||
|
$$('cmd_win_cancel_pay_close2').attachEvent('onItemClick', cmd_win_cancel_pay_close2_click)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue