Fix - Issue #136
This commit is contained in:
parent
c38631daba
commit
ddb3588995
|
@ -320,6 +320,9 @@ class StorageEngine(object):
|
||||||
return main.Productos.add(values)
|
return main.Productos.add(values)
|
||||||
|
|
||||||
def invoice(self, values, user):
|
def invoice(self, values, user):
|
||||||
|
if 'opt' in values:
|
||||||
|
return main.Facturas.opt(values, user)
|
||||||
|
|
||||||
id = int(values.pop('id', '0'))
|
id = int(values.pop('id', '0'))
|
||||||
if id:
|
if id:
|
||||||
return main.Facturas.actualizar(values, id)
|
return main.Facturas.actualizar(values, id)
|
||||||
|
|
|
@ -4178,6 +4178,35 @@ class Facturas(BaseModel):
|
||||||
|
|
||||||
return {'status': 'server'}
|
return {'status': 'server'}
|
||||||
|
|
||||||
|
def _set_invoices_payed(self, ids, user):
|
||||||
|
ids = util.loads(ids)
|
||||||
|
ok_ids = []
|
||||||
|
for id in ids:
|
||||||
|
with database_proxy.atomic() as txn:
|
||||||
|
obj = Facturas.get(Facturas.id==id)
|
||||||
|
obj.pagada = True
|
||||||
|
saldo = obj.saldo
|
||||||
|
obj.saldo = 0.00
|
||||||
|
obj.save()
|
||||||
|
q = (Socios
|
||||||
|
.update(saldo_cliente=Socios.saldo_cliente - saldo)
|
||||||
|
.where(Socios.id==obj.cliente.id)
|
||||||
|
)
|
||||||
|
q.execute()
|
||||||
|
ok_ids.append(id)
|
||||||
|
|
||||||
|
if ok_ids:
|
||||||
|
return {'ok': True, 'rows': ok_ids}
|
||||||
|
|
||||||
|
return {'ok': False}
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def opt(cls, args, user):
|
||||||
|
if args['opt'] == 'invoicepayed':
|
||||||
|
return cls._set_invoices_payed(cls, args['ids'], user)
|
||||||
|
|
||||||
|
return {'ok': False}
|
||||||
|
|
||||||
|
|
||||||
class PreFacturas(BaseModel):
|
class PreFacturas(BaseModel):
|
||||||
cliente = ForeignKeyField(Socios)
|
cliente = ForeignKeyField(Socios)
|
||||||
|
|
|
@ -10,6 +10,7 @@ var bancos_controllers = {
|
||||||
$$('cmd_guardar_retiro').attachEvent('onItemClick', cmd_guardar_retiro_click)
|
$$('cmd_guardar_retiro').attachEvent('onItemClick', cmd_guardar_retiro_click)
|
||||||
$$('cmd_guardar_deposito').attachEvent('onItemClick', cmd_guardar_deposito_click)
|
$$('cmd_guardar_deposito').attachEvent('onItemClick', cmd_guardar_deposito_click)
|
||||||
$$('cmd_cancelar_movimiento').attachEvent('onItemClick', cmd_cancelar_movimiento_click)
|
$$('cmd_cancelar_movimiento').attachEvent('onItemClick', cmd_cancelar_movimiento_click)
|
||||||
|
$$('cmd_invoice_payed').attachEvent('onItemClick', cmd_invoice_payed_click)
|
||||||
$$('txt_retiro_importe').attachEvent('onChange', txt_retiro_importe_change)
|
$$('txt_retiro_importe').attachEvent('onChange', txt_retiro_importe_change)
|
||||||
$$('txt_deposito_importe').attachEvent('onChange', txt_deposito_importe_change)
|
$$('txt_deposito_importe').attachEvent('onChange', txt_deposito_importe_change)
|
||||||
$$('grid_cfdi_este_deposito').attachEvent('onAfterDrop', grid_cfdi_este_deposito_after_drop)
|
$$('grid_cfdi_este_deposito').attachEvent('onAfterDrop', grid_cfdi_este_deposito_after_drop)
|
||||||
|
@ -605,3 +606,54 @@ function cmd_cancelar_movimiento_click(){
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function set_invoices_payed(rows){
|
||||||
|
var ids = []
|
||||||
|
|
||||||
|
for(var row of rows){
|
||||||
|
ids.push(row.id)
|
||||||
|
}
|
||||||
|
|
||||||
|
webix.ajax().post('/invoices', {opt: 'invoicepayed', ids: ids}, {
|
||||||
|
error:function(text, data, XmlHttpRequest){
|
||||||
|
msg = 'Ocurrio un error, consulta a soporte técnico'
|
||||||
|
msg_error(msg)
|
||||||
|
},
|
||||||
|
success:function(text, data, XmlHttpRequest){
|
||||||
|
var values = data.json()
|
||||||
|
if(values.ok){
|
||||||
|
msg = 'Facturas marcadas pagadas correctamente'
|
||||||
|
$$('grid_cfdi_por_pagar').remove(values.rows)
|
||||||
|
msg_ok(msg)
|
||||||
|
}else{
|
||||||
|
msg_error(values.msg)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function cmd_invoice_payed_click(){
|
||||||
|
var rows = $$('grid_cfdi_por_pagar').getSelectedItem(true)
|
||||||
|
if (rows.length == 0){
|
||||||
|
msg_error('Selecciona al menos una factura por pagar')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
msg = '¿Estás seguro de marcar como pagadas las facturas seleccionadas?<BR><BR>'
|
||||||
|
msg += 'No se relacionarán con ningún depósito.<BR><BR>ESTA ACCIÓN NO SE PUEDE DESHACER'
|
||||||
|
webix.confirm({
|
||||||
|
title: 'Facturas Pagadas',
|
||||||
|
ok: 'Si',
|
||||||
|
cancel: 'No',
|
||||||
|
type: 'confirm-error',
|
||||||
|
text: msg,
|
||||||
|
callback: function(result){
|
||||||
|
if (result){
|
||||||
|
set_invoices_payed(rows)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
|
@ -99,6 +99,7 @@ var grid_cfdi_por_pagar = {
|
||||||
view: 'datatable',
|
view: 'datatable',
|
||||||
id: 'grid_cfdi_por_pagar',
|
id: 'grid_cfdi_por_pagar',
|
||||||
select: 'row',
|
select: 'row',
|
||||||
|
multiselect: true,
|
||||||
autoConfig: false,
|
autoConfig: false,
|
||||||
adjust: true,
|
adjust: true,
|
||||||
height: 250,
|
height: 250,
|
||||||
|
@ -217,7 +218,11 @@ var controls_banco_deposito = [
|
||||||
name: 'deposito_descripcion', labelAlign: 'right', required: true,
|
name: 'deposito_descripcion', labelAlign: 'right', required: true,
|
||||||
labelWidth: 125, height: 70},
|
labelWidth: 125, height: 70},
|
||||||
]},
|
]},
|
||||||
|
{cols: [
|
||||||
{view: 'label', label: '<b>Facturas por pagar: </b>'},
|
{view: 'label', label: '<b>Facturas por pagar: </b>'},
|
||||||
|
{view: 'button', id: 'cmd_invoice_payed', label: 'Pagada directamente',
|
||||||
|
type: 'iconButton', autowidth: true, icon: 'check-circle'},
|
||||||
|
]},
|
||||||
grid_cfdi_por_pagar,
|
grid_cfdi_por_pagar,
|
||||||
{view: 'label', label: '<b>Facturas a pagar en este depósito: </b>'},
|
{view: 'label', label: '<b>Facturas a pagar en este depósito: </b>'},
|
||||||
grid_cfdi_este_deposito,
|
grid_cfdi_este_deposito,
|
||||||
|
|
Loading…
Reference in New Issue