forked from elmau/empresa-libre
Calcular precio sin impuestos
This commit is contained in:
parent
d5027988dd
commit
ff0a2f27b1
|
@ -160,6 +160,7 @@ class Configuracion(BaseModel):
|
||||||
fields = (
|
fields = (
|
||||||
'chk_config_cuenta_predial',
|
'chk_config_cuenta_predial',
|
||||||
'chk_config_codigo_barras',
|
'chk_config_codigo_barras',
|
||||||
|
'chk_config_precio_con_impuestos',
|
||||||
)
|
)
|
||||||
data = (Configuracion
|
data = (Configuracion
|
||||||
.select()
|
.select()
|
||||||
|
@ -200,6 +201,7 @@ class Configuracion(BaseModel):
|
||||||
'chk_config_anticipo',
|
'chk_config_anticipo',
|
||||||
'chk_config_cuenta_predial',
|
'chk_config_cuenta_predial',
|
||||||
'chk_config_codigo_barras',
|
'chk_config_codigo_barras',
|
||||||
|
'chk_config_precio_con_impuestos',
|
||||||
'chk_config_ine',
|
'chk_config_ine',
|
||||||
'chk_usar_punto_de_venta',
|
'chk_usar_punto_de_venta',
|
||||||
)
|
)
|
||||||
|
|
|
@ -54,6 +54,7 @@ var controllers = {
|
||||||
$$('chk_config_ine').attachEvent('onItemClick', chk_config_item_click)
|
$$('chk_config_ine').attachEvent('onItemClick', chk_config_item_click)
|
||||||
$$('chk_config_cuenta_predial').attachEvent('onItemClick', chk_config_item_click)
|
$$('chk_config_cuenta_predial').attachEvent('onItemClick', chk_config_item_click)
|
||||||
$$('chk_config_codigo_barras').attachEvent('onItemClick', chk_config_item_click)
|
$$('chk_config_codigo_barras').attachEvent('onItemClick', chk_config_item_click)
|
||||||
|
$$('chk_config_precio_con_impuestos').attachEvent('onItemClick', chk_config_item_click)
|
||||||
$$('chk_usar_punto_de_venta').attachEvent('onItemClick', chk_config_item_click)
|
$$('chk_usar_punto_de_venta').attachEvent('onItemClick', chk_config_item_click)
|
||||||
|
|
||||||
$$('cmd_subir_bdfl').attachEvent('onItemClick', cmd_subir_bdfl_click)
|
$$('cmd_subir_bdfl').attachEvent('onItemClick', cmd_subir_bdfl_click)
|
||||||
|
|
|
@ -49,15 +49,7 @@ var controllers = {
|
||||||
$$("es_proveedor").attachEvent( "onChange", is_supplier_change)
|
$$("es_proveedor").attachEvent( "onChange", is_supplier_change)
|
||||||
$$("rfc").attachEvent( "onBlur", rfc_lost_focus)
|
$$("rfc").attachEvent( "onBlur", rfc_lost_focus)
|
||||||
$$('multi').attachEvent('onViewChange', multi_change)
|
$$('multi').attachEvent('onViewChange', multi_change)
|
||||||
//~ Products
|
|
||||||
$$("cmd_new_product").attachEvent("onItemClick", cmd_new_product_click)
|
|
||||||
$$("cmd_edit_product").attachEvent("onItemClick", cmd_edit_product_click)
|
|
||||||
$$("cmd_delete_product").attachEvent("onItemClick", cmd_delete_product_click)
|
|
||||||
$$("cmd_save_product").attachEvent("onItemClick", cmd_save_product_click)
|
|
||||||
$$("cmd_cancel_product").attachEvent("onItemClick", cmd_cancel_product_click)
|
|
||||||
$$("chk_automatica").attachEvent("onChange", chk_automatica_change)
|
|
||||||
$$("valor_unitario").attachEvent("onChange", valor_unitario_change)
|
|
||||||
$$("clave_sat").attachEvent('onSearchIconClick', clave_sat_icon_click)
|
|
||||||
//~ Invoices
|
//~ Invoices
|
||||||
$$('cmd_new_invoice').attachEvent("onItemClick", cmd_new_invoice_click)
|
$$('cmd_new_invoice').attachEvent("onItemClick", cmd_new_invoice_click)
|
||||||
$$('cmd_refacturar').attachEvent("onItemClick", cmd_refacturar_click)
|
$$('cmd_refacturar').attachEvent("onItemClick", cmd_refacturar_click)
|
||||||
|
@ -95,6 +87,7 @@ var controllers = {
|
||||||
|
|
||||||
webix.extend($$('grid_invoices'), webix.ProgressBar)
|
webix.extend($$('grid_invoices'), webix.ProgressBar)
|
||||||
|
|
||||||
|
products_controllers.init()
|
||||||
bancos_controllers.init()
|
bancos_controllers.init()
|
||||||
tickets_controllers.init()
|
tickets_controllers.init()
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,21 @@
|
||||||
|
|
||||||
|
|
||||||
|
var products_controllers = {
|
||||||
|
init: function(){
|
||||||
|
$$('cmd_new_product').attachEvent('onItemClick', cmd_new_product_click)
|
||||||
|
$$("cmd_edit_product").attachEvent("onItemClick", cmd_edit_product_click)
|
||||||
|
$$("cmd_delete_product").attachEvent("onItemClick", cmd_delete_product_click)
|
||||||
|
$$("cmd_save_product").attachEvent("onItemClick", cmd_save_product_click)
|
||||||
|
$$("cmd_cancel_product").attachEvent("onItemClick", cmd_cancel_product_click)
|
||||||
|
$$("chk_automatica").attachEvent("onChange", chk_automatica_change)
|
||||||
|
$$("valor_unitario").attachEvent("onChange", valor_unitario_change)
|
||||||
|
//~ $$("clave_sat").attachEvent('onSearchIconClick', clave_sat_icon_click)
|
||||||
|
$$('precio_con_impuestos').attachEvent('onChange', precio_con_impuestos_change)
|
||||||
|
$$('precio_con_impuestos').attachEvent('onTimedKeyPress', precio_con_impuestos_key_up);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function configurar_productos(){
|
function configurar_productos(){
|
||||||
webix.ajax().get('/config', {'fields': 'productos'}, {
|
webix.ajax().get('/config', {'fields': 'productos'}, {
|
||||||
error: function(text, data, xhr) {
|
error: function(text, data, xhr) {
|
||||||
|
@ -11,6 +27,7 @@ function configurar_productos(){
|
||||||
//~ showvar(values)
|
//~ showvar(values)
|
||||||
show('cuenta_predial', values.chk_config_cuenta_predial)
|
show('cuenta_predial', values.chk_config_cuenta_predial)
|
||||||
show('codigo_barras', values.chk_config_codigo_barras)
|
show('codigo_barras', values.chk_config_codigo_barras)
|
||||||
|
show('precio_con_impuestos', values.chk_config_precio_con_impuestos)
|
||||||
$$('unidad').setValue(values.default_unidad)
|
$$('unidad').setValue(values.default_unidad)
|
||||||
$$('grid_product_taxes').select(values.default_tax)
|
$$('grid_product_taxes').select(values.default_tax)
|
||||||
}
|
}
|
||||||
|
@ -231,6 +248,49 @@ function valor_unitario_change(new_value, old_value){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function clave_sat_icon_click(){
|
function precio_con_impuestos_change(new_value, old_value){
|
||||||
show('Buscar SAT')
|
if(!isFinite(new_value)){
|
||||||
|
this.config.value = old_value
|
||||||
|
this.refresh()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//~ function clave_sat_icon_click(){
|
||||||
|
//~ show('Buscar SAT')
|
||||||
|
//~ }
|
||||||
|
|
||||||
|
function calcular_sin_impuestos(value, taxes){
|
||||||
|
var vu = $$('valor_unitario')
|
||||||
|
var precio = value
|
||||||
|
|
||||||
|
taxes.forEach(function(tax){
|
||||||
|
var tasa = 1.00 + tax.tasa.to_float()
|
||||||
|
if(tax.tipo == 'T' && tax.name == 'IVA'){
|
||||||
|
precio = (value / tasa).round(DECIMALES)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
vu.setValue(precio)
|
||||||
|
}
|
||||||
|
|
||||||
|
function precio_con_impuestos_key_up(){
|
||||||
|
var value = this.getValue()
|
||||||
|
|
||||||
|
if(!value){
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var taxes = $$('grid_product_taxes').getSelectedItem(true)
|
||||||
|
if (taxes.length == 0){
|
||||||
|
msg = 'Selecciona al menos un impuesto'
|
||||||
|
msg_error(msg)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!isFinite(value)){
|
||||||
|
msg = 'Captura un valor válido'
|
||||||
|
msg_error(msg)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
calcular_sin_impuestos(parseFloat(value), taxes)
|
||||||
}
|
}
|
|
@ -498,7 +498,9 @@ var options_admin_otros = [
|
||||||
labelRight: 'Mostrar cuenta predial'},
|
labelRight: 'Mostrar cuenta predial'},
|
||||||
{view: 'checkbox', id: 'chk_config_codigo_barras', labelWidth: 0,
|
{view: 'checkbox', id: 'chk_config_codigo_barras', labelWidth: 0,
|
||||||
labelRight: 'Mostrar código de barras'},
|
labelRight: 'Mostrar código de barras'},
|
||||||
{}]},
|
{view: 'checkbox', id: 'chk_config_precio_con_impuestos', labelWidth: 0,
|
||||||
|
labelRight: 'Mostrar precio con impuestos'},
|
||||||
|
]},
|
||||||
{maxHeight: 20},
|
{maxHeight: 20},
|
||||||
{template: 'Complementos', type: 'section'},
|
{template: 'Complementos', type: 'section'},
|
||||||
{cols: [{maxWidth: 15},
|
{cols: [{maxWidth: 15},
|
||||||
|
|
|
@ -123,10 +123,16 @@ var controls_generals = [
|
||||||
labelAlign: 'right', label: 'Etiquetas',
|
labelAlign: 'right', label: 'Etiquetas',
|
||||||
placeholder: 'Separadas por comas'}
|
placeholder: 'Separadas por comas'}
|
||||||
]},
|
]},
|
||||||
{cols: [{view: "currency", type: "text", id: "valor_unitario",
|
{cols: [
|
||||||
|
{view: "currency", type: "text", id: "valor_unitario",
|
||||||
name: "valor_unitario", label: "Valor Unitario", width: 300,
|
name: "valor_unitario", label: "Valor Unitario", width: 300,
|
||||||
labelWidth: 130, labelAlign: "right", required: true,
|
labelWidth: 130, labelAlign: "right", required: true,
|
||||||
invalidMessage: "Captura un valor númerico", inputAlign: "right" },{}]},
|
invalidMessage: "Captura un valor númerico", inputAlign: "right"},
|
||||||
|
{view: 'currency', type: 'text', id: 'precio_con_impuestos',
|
||||||
|
name: 'precio_con_impuestos', label: 'Con Impuestos', width: 300,
|
||||||
|
labelWidth: 115, labelAlign: 'right', required: false,
|
||||||
|
invalidMessage: 'Captura un valor númerico', inputAlign: 'right'},
|
||||||
|
{},]},
|
||||||
{cols: [
|
{cols: [
|
||||||
{view: 'checkbox', id: 'inventario', name: 'inventario', hidden: true,
|
{view: 'checkbox', id: 'inventario', name: 'inventario', hidden: true,
|
||||||
label: 'Inventario', labelAlign: 'right', labelWidth: 130},
|
label: 'Inventario', labelAlign: 'right', labelWidth: 130},
|
||||||
|
|
Loading…
Reference in New Issue