Validate stock when invoice
This commit is contained in:
parent
0442019ea5
commit
e9eeab8c2c
|
@ -1,4 +1,9 @@
|
||||||
v 1.42.1 [00-Jun-2021]
|
v 1.43.0 [00-Jun-2021]
|
||||||
|
----------------------
|
||||||
|
- Soporte para multialmacen
|
||||||
|
|
||||||
|
|
||||||
|
v 1.42.1 [31-May-2021]
|
||||||
----------------------
|
----------------------
|
||||||
- Error - Ticket #5
|
- Error - Ticket #5
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
# ~ Empresa Libre
|
# ~ Empresa Libre
|
||||||
# ~ Copyright (C) 2016-2018 Mauricio Baeza Servin (web@correolibre.net)
|
# ~ Copyright (C) 2016-2021 Mauricio Baeza Servin (public@correolibre.net)
|
||||||
# ~
|
# ~
|
||||||
# ~ This program is free software: you can redistribute it and/or modify
|
# ~ This program is free software: you can redistribute it and/or modify
|
||||||
# ~ it under the terms of the GNU General Public License as published by
|
# ~ it under the terms of the GNU General Public License as published by
|
||||||
|
@ -16,6 +16,7 @@
|
||||||
# ~ You should have received a copy of the GNU General Public License
|
# ~ You should have received a copy of the GNU General Public License
|
||||||
# ~ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# ~ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
import sqlite3
|
import sqlite3
|
||||||
|
@ -3553,7 +3554,9 @@ class Productos(BaseModel):
|
||||||
Productos.descripcion,
|
Productos.descripcion,
|
||||||
SATUnidades.id.alias('unidad'),
|
SATUnidades.id.alias('unidad'),
|
||||||
Productos.valor_unitario,
|
Productos.valor_unitario,
|
||||||
Productos.descuento)
|
Productos.descuento,
|
||||||
|
Productos.inventario,
|
||||||
|
Productos.existencia)
|
||||||
.join(SATUnidades).switch(Productos)
|
.join(SATUnidades).switch(Productos)
|
||||||
.where((Productos.es_activo==True) &
|
.where((Productos.es_activo==True) &
|
||||||
((Productos.clave==clave) | (Productos.codigo_barras==clave)))
|
((Productos.clave==clave) | (Productos.codigo_barras==clave)))
|
||||||
|
@ -3567,7 +3570,8 @@ class Productos(BaseModel):
|
||||||
model_pt.productos_id.alias('product'),
|
model_pt.productos_id.alias('product'),
|
||||||
model_pt.satimpuestos_id.alias('tax'))
|
model_pt.satimpuestos_id.alias('tax'))
|
||||||
.where(model_pt.productos_id==id).dicts())
|
.where(model_pt.productos_id==id).dicts())
|
||||||
return {'ok': True, 'row': row[0], 'taxes': taxes}
|
product = row[0]
|
||||||
|
return {'ok': True, 'row': product, 'taxes': taxes}
|
||||||
|
|
||||||
return {'ok': False}
|
return {'ok': False}
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ except ImportError:
|
||||||
|
|
||||||
|
|
||||||
DEBUG = DEBUG
|
DEBUG = DEBUG
|
||||||
VERSION = '1.42.1'
|
VERSION = '1.43.0'
|
||||||
EMAIL_SUPPORT = ('soporte@empresalibre.mx',)
|
EMAIL_SUPPORT = ('soporte@empresalibre.mx',)
|
||||||
TITLE_APP = '{} v{}'.format(TITLE_APP, VERSION)
|
TITLE_APP = '{} v{}'.format(TITLE_APP, VERSION)
|
||||||
|
|
||||||
|
|
|
@ -909,9 +909,9 @@ function calcular_impuestos(){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function set_product(values){
|
function set_product(data){
|
||||||
var taxes = values.taxes
|
var taxes = data.taxes
|
||||||
var values = values.row
|
var values = data.row
|
||||||
var form = $$('form_invoice')
|
var form = $$('form_invoice')
|
||||||
var row = undefined
|
var row = undefined
|
||||||
|
|
||||||
|
@ -928,17 +928,33 @@ function set_product(values){
|
||||||
if (row == undefined){
|
if (row == undefined){
|
||||||
values['cantidad'] = 1
|
values['cantidad'] = 1
|
||||||
values['importe'] = values['valor_unitario']
|
values['importe'] = values['valor_unitario']
|
||||||
grid.add(values)
|
//~ grid.add(values)
|
||||||
} else {
|
} else {
|
||||||
values['cantidad'] = parseFloat(row.cantidad) + 1
|
values['cantidad'] = parseFloat(row.cantidad) + 1
|
||||||
values['descuento'] = parseFloat(row.descuento)
|
values['descuento'] = parseFloat(row.descuento)
|
||||||
values['valor_unitario'] = parseFloat(row.valor_unitario)
|
values['valor_unitario'] = parseFloat(row.valor_unitario)
|
||||||
var precio_final = values['valor_unitario'] - values['descuento']
|
var precio_final = values['valor_unitario'] - values['descuento']
|
||||||
values['importe'] = (precio_final * values['cantidad']).round(DECIMALES)
|
values['importe'] = (precio_final * values['cantidad']).round(DECIMALES)
|
||||||
grid.updateItem(row.id, values)
|
//~ grid.updateItem(row.id, values)
|
||||||
}
|
}
|
||||||
form.setValues({search_product_id: '', search_product_name: ''}, true)
|
form.setValues({search_product_id: '', search_product_name: ''}, true)
|
||||||
|
|
||||||
|
|
||||||
|
//~ Validate stock
|
||||||
|
if(values.inventario){
|
||||||
|
if(values.cantidad > values.existencia){
|
||||||
|
msg_error('No hay suficiente existencia de este producto')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(row == undefined){
|
||||||
|
grid.add(values)
|
||||||
|
}else{
|
||||||
|
grid.updateItem(row.id, values)
|
||||||
|
}
|
||||||
|
|
||||||
for(var v of taxes){
|
for(var v of taxes){
|
||||||
var pt = table_pt.findOne(v)
|
var pt = table_pt.findOne(v)
|
||||||
if(pt === null){
|
if(pt === null){
|
||||||
|
@ -1071,6 +1087,20 @@ function grid_details_before_edit_stop(state, editor){
|
||||||
}
|
}
|
||||||
|
|
||||||
cantidad = cantidad.round(DECIMALES)
|
cantidad = cantidad.round(DECIMALES)
|
||||||
|
|
||||||
|
//~ 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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
grid.blockEvent()
|
grid.blockEvent()
|
||||||
state.value = cantidad
|
state.value = cantidad
|
||||||
grid.unblockEvent()
|
grid.unblockEvent()
|
||||||
|
|
|
@ -359,6 +359,8 @@ var grid_details_cols = [
|
||||||
format: webix.i18n.priceFormat, css: 'right'},
|
format: webix.i18n.priceFormat, css: 'right'},
|
||||||
{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'},
|
||||||
|
{id: "inventario", hidden: true},
|
||||||
|
{id: "existencia", hidden: true},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue