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)
|
form.setValues({search_product_id: '', search_product_name: ''}, true)
|
||||||
|
|
||||||
|
|
||||||
//~ Validate stock
|
//~ Validate stock
|
||||||
if(values.inventario){
|
if(values.inventario){
|
||||||
if(values.cantidad > values.existencia){
|
if(values.cantidad > values.existencia){
|
||||||
|
@ -948,7 +947,6 @@ function set_product(data){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(row == undefined){
|
if(row == undefined){
|
||||||
grid.add(values)
|
grid.add(values)
|
||||||
}else{
|
}else{
|
||||||
|
|
|
@ -342,17 +342,32 @@ function agregar_producto(values){
|
||||||
producto['valor_unitario'] = calcular_precio_con_impuestos(
|
producto['valor_unitario'] = calcular_precio_con_impuestos(
|
||||||
parseFloat(producto['valor_unitario']), taxes)
|
parseFloat(producto['valor_unitario']), taxes)
|
||||||
producto['importe'] = producto['valor_unitario']
|
producto['importe'] = producto['valor_unitario']
|
||||||
var id = grid.add(producto, 0)
|
//~ var id = grid.add(producto, 0)
|
||||||
edit_cant(id)
|
//~ edit_cant(id)
|
||||||
}else{
|
}else{
|
||||||
producto['cantidad'] = parseFloat(row.cantidad) + 1
|
producto['cantidad'] = parseFloat(row.cantidad) + 1
|
||||||
producto['descuento'] = parseFloat(row.descuento)
|
producto['descuento'] = parseFloat(row.descuento)
|
||||||
producto['valor_unitario'] = parseFloat(row.valor_unitario)
|
producto['valor_unitario'] = parseFloat(row.valor_unitario)
|
||||||
precio_final = producto['valor_unitario'] - producto['descuento']
|
precio_final = producto['valor_unitario'] - producto['descuento']
|
||||||
producto['importe'] = (precio_final * producto['cantidad']).round(DECIMALES)
|
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)
|
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()
|
grid.unblockEvent()
|
||||||
return true
|
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 valor_unitario = parseFloat(row['valor_unitario'])
|
||||||
var descuento = parseFloat(row['descuento'])
|
var descuento = parseFloat(row['descuento'])
|
||||||
}
|
}
|
||||||
|
|
|
@ -145,6 +145,8 @@ var grid_tdetails_cols = [
|
||||||
{id: "importe", header:{text: 'Importe', css: 'center'}, width: 150,
|
{id: "importe", header:{text: 'Importe', css: 'center'}, width: 150,
|
||||||
format: webix.i18n.priceFormat, css: 'right',
|
format: webix.i18n.priceFormat, css: 'right',
|
||||||
footer: {content: 'summColumn', css: 'right_footer2'}},
|
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)
|
$$('cmd_ticket_save_note').attachEvent('onItemClick', cmd_ticket_save_note_click)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue