Validate stock in ticket
This commit is contained in:
parent
e9eeab8c2c
commit
cf35cd08cd
|
@ -939,7 +939,6 @@ function set_product(data){
|
|||
}
|
||||
form.setValues({search_product_id: '', search_product_name: ''}, true)
|
||||
|
||||
|
||||
//~ Validate stock
|
||||
if(values.inventario){
|
||||
if(values.cantidad > values.existencia){
|
||||
|
@ -948,7 +947,6 @@ function set_product(data){
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
if(row == undefined){
|
||||
grid.add(values)
|
||||
}else{
|
||||
|
|
|
@ -342,17 +342,32 @@ function agregar_producto(values){
|
|||
producto['valor_unitario'] = calcular_precio_con_impuestos(
|
||||
parseFloat(producto['valor_unitario']), taxes)
|
||||
producto['importe'] = producto['valor_unitario']
|
||||
var id = grid.add(producto, 0)
|
||||
edit_cant(id)
|
||||
//~ var id = grid.add(producto, 0)
|
||||
//~ edit_cant(id)
|
||||
}else{
|
||||
producto['cantidad'] = parseFloat(row.cantidad) + 1
|
||||
producto['descuento'] = parseFloat(row.descuento)
|
||||
producto['valor_unitario'] = parseFloat(row.valor_unitario)
|
||||
precio_final = producto['valor_unitario'] - producto['descuento']
|
||||
producto['importe'] = (precio_final * producto['cantidad']).round(DECIMALES)
|
||||
grid.updateItem(row.id, producto)
|
||||
//~ grid.updateItem(row.id, producto)
|
||||
}
|
||||
form.setValues({tsearch_product_key: '', tsearch_product_name: ''}, true)
|
||||
|
||||
//~ Validate stock
|
||||
if(producto.inventario){
|
||||
if(producto.cantidad > producto.existencia){
|
||||
msg_error('No hay suficiente existencia de este producto')
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if(row == undefined){
|
||||
var id = grid.add(producto, 0)
|
||||
edit_cant(id)
|
||||
}else{
|
||||
grid.updateItem(row.id, producto)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -417,6 +432,20 @@ function grid_tickets_details_before_edit_stop(state, editor){
|
|||
grid.unblockEvent()
|
||||
return true
|
||||
}
|
||||
|
||||
//~ Validate stock
|
||||
if(row['inventario']){
|
||||
if(cantidad > row['existencia']){
|
||||
msg = 'No hay suficiente existencia de este producto'
|
||||
msg_error(msg)
|
||||
grid.blockEvent()
|
||||
state.value = state.old
|
||||
grid.editCancel()
|
||||
grid.unblockEvent()
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
var valor_unitario = parseFloat(row['valor_unitario'])
|
||||
var descuento = parseFloat(row['descuento'])
|
||||
}
|
||||
|
|
|
@ -145,6 +145,8 @@ var grid_tdetails_cols = [
|
|||
{id: "importe", header:{text: 'Importe', css: 'center'}, width: 150,
|
||||
format: webix.i18n.priceFormat, css: 'right',
|
||||
footer: {content: 'summColumn', css: 'right_footer2'}},
|
||||
{id: "inventario", hidden: true},
|
||||
{id: "existencia", hidden: true},
|
||||
]
|
||||
|
||||
|
||||
|
@ -478,4 +480,4 @@ var win_ticket_notes = {
|
|||
})
|
||||
$$('cmd_ticket_save_note').attachEvent('onItemClick', cmd_ticket_save_note_click)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue