forked from elmau/empresa-libre
Capturar precio con impuestos la facturar
This commit is contained in:
commit
67ae4d0319
|
@ -221,6 +221,7 @@ def config_timbrar():
|
||||||
'cfdi_show_pedimento': Configuracion.get_bool('chk_config_show_pedimento'),
|
'cfdi_show_pedimento': Configuracion.get_bool('chk_config_show_pedimento'),
|
||||||
'cfdi_tax_locales': Configuracion.get_bool('chk_config_tax_locales'),
|
'cfdi_tax_locales': Configuracion.get_bool('chk_config_tax_locales'),
|
||||||
'cfdi_tax_decimals': Configuracion.get_bool('chk_config_tax_decimals'),
|
'cfdi_tax_decimals': Configuracion.get_bool('chk_config_tax_decimals'),
|
||||||
|
'cfdi_with_taxes': Configuracion.get_bool('chk_config_price_with_taxes_in_invoice'),
|
||||||
}
|
}
|
||||||
|
|
||||||
return conf
|
return conf
|
||||||
|
@ -306,6 +307,8 @@ class Configuracion(BaseModel):
|
||||||
'chk_config_open_pdf',
|
'chk_config_open_pdf',
|
||||||
'chk_config_show_pedimento',
|
'chk_config_show_pedimento',
|
||||||
'chk_config_tax_locales',
|
'chk_config_tax_locales',
|
||||||
|
'chk_config_tax_decimals',
|
||||||
|
'chk_config_price_with_taxes_in_invoice',
|
||||||
'chk_config_anticipo',
|
'chk_config_anticipo',
|
||||||
'chk_config_cuenta_predial',
|
'chk_config_cuenta_predial',
|
||||||
'chk_config_codigo_barras',
|
'chk_config_codigo_barras',
|
||||||
|
|
|
@ -59,6 +59,8 @@ var controllers = {
|
||||||
$$('chk_config_open_pdf').attachEvent('onItemClick', chk_config_item_click)
|
$$('chk_config_open_pdf').attachEvent('onItemClick', chk_config_item_click)
|
||||||
$$('chk_config_show_pedimento').attachEvent('onItemClick', chk_config_item_click)
|
$$('chk_config_show_pedimento').attachEvent('onItemClick', chk_config_item_click)
|
||||||
$$('chk_config_tax_locales').attachEvent('onItemClick', chk_config_item_click)
|
$$('chk_config_tax_locales').attachEvent('onItemClick', chk_config_item_click)
|
||||||
|
$$('chk_config_tax_decimals').attachEvent('onItemClick', chk_config_item_click)
|
||||||
|
$$('chk_config_price_with_taxes_in_invoice').attachEvent('onItemClick', chk_config_item_click)
|
||||||
$$('chk_config_anticipo').attachEvent('onItemClick', chk_config_item_click)
|
$$('chk_config_anticipo').attachEvent('onItemClick', chk_config_item_click)
|
||||||
$$('chk_config_ine').attachEvent('onItemClick', chk_config_item_click)
|
$$('chk_config_ine').attachEvent('onItemClick', chk_config_item_click)
|
||||||
$$('chk_config_edu').attachEvent('onItemClick', chk_config_item_click)
|
$$('chk_config_edu').attachEvent('onItemClick', chk_config_item_click)
|
||||||
|
|
|
@ -164,6 +164,7 @@ function default_config(){
|
||||||
cfg_invoice['open_pdf'] = values.cfdi_open_pdf
|
cfg_invoice['open_pdf'] = values.cfdi_open_pdf
|
||||||
cfg_invoice['tax_locales'] = values.cfdi_tax_locales
|
cfg_invoice['tax_locales'] = values.cfdi_tax_locales
|
||||||
cfg_invoice['tax_decimals'] = values.cfdi_tax_decimals
|
cfg_invoice['tax_decimals'] = values.cfdi_tax_decimals
|
||||||
|
cfg_invoice['with_taxes'] = values.cfdi_with_taxes
|
||||||
if(values.cfdi_show_pedimento){
|
if(values.cfdi_show_pedimento){
|
||||||
$$('grid_details').showColumn('pedimento')
|
$$('grid_details').showColumn('pedimento')
|
||||||
}
|
}
|
||||||
|
@ -171,6 +172,25 @@ function default_config(){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function price_without_taxes(price, id){
|
||||||
|
var final_price = price
|
||||||
|
|
||||||
|
query = table_pt.chain().find({'product': id}).data()
|
||||||
|
for(var tax of query){
|
||||||
|
impuesto = table_taxes.findOne({'id': tax.tax})
|
||||||
|
if(impuesto.tipo == 'E'){
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
var tasa = 1.00 + impuesto.tasa.to_float()
|
||||||
|
if(impuesto.tipo == 'T' && impuesto.name == 'IVA'){
|
||||||
|
final_price = (price / tasa).round(DECIMALES)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return final_price
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function cmd_new_invoice_click(id, e, node){
|
function cmd_new_invoice_click(id, e, node){
|
||||||
var form = $$('form_invoice')
|
var form = $$('form_invoice')
|
||||||
var grid_totals = $$('grid_totals')
|
var grid_totals = $$('grid_totals')
|
||||||
|
@ -966,8 +986,7 @@ function grid_details_before_edit_stop(state, editor){
|
||||||
}
|
}
|
||||||
|
|
||||||
if(editor.column == 'valor_unitario'){
|
if(editor.column == 'valor_unitario'){
|
||||||
var valor_unitario = parseFloat(state.value)
|
if(isNaN(state.value)){
|
||||||
if(isNaN(valor_unitario)){
|
|
||||||
msg = 'El valor unitario debe ser un número'
|
msg = 'El valor unitario debe ser un número'
|
||||||
msg_error(msg)
|
msg_error(msg)
|
||||||
grid.blockEvent()
|
grid.blockEvent()
|
||||||
|
@ -976,6 +995,14 @@ function grid_details_before_edit_stop(state, editor){
|
||||||
grid.unblockEvent()
|
grid.unblockEvent()
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(cfg_invoice['with_taxes']){
|
||||||
|
var valor_unitario = price_without_taxes(parseFloat(state.value), row.id)
|
||||||
|
grid.blockEvent()
|
||||||
|
state.value = valor_unitario
|
||||||
|
grid.unblockEvent()
|
||||||
|
}
|
||||||
|
var valor_unitario = parseFloat(state.value)
|
||||||
var cantidad = parseFloat(row['cantidad'])
|
var cantidad = parseFloat(row['cantidad'])
|
||||||
var descuento = parseFloat(row['descuento'])
|
var descuento = parseFloat(row['descuento'])
|
||||||
}
|
}
|
||||||
|
@ -999,7 +1026,6 @@ function grid_details_before_edit_stop(state, editor){
|
||||||
row['importe'] = (cantidad * precio_final).round(DECIMALES)
|
row['importe'] = (cantidad * precio_final).round(DECIMALES)
|
||||||
|
|
||||||
grid.refresh()
|
grid.refresh()
|
||||||
//~ calculate_taxes()
|
|
||||||
calcular_impuestos()
|
calcular_impuestos()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1009,7 +1035,6 @@ function grid_details_click(id, e, node){
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
grid.remove(id.row)
|
grid.remove(id.row)
|
||||||
//~ calculate_taxes()
|
|
||||||
calcular_impuestos()
|
calcular_impuestos()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -513,6 +513,10 @@ var options_admin_otros = [
|
||||||
{cols: [{maxWidth: 15},
|
{cols: [{maxWidth: 15},
|
||||||
{view: 'checkbox', id: 'chk_config_tax_locales', labelWidth: 0,
|
{view: 'checkbox', id: 'chk_config_tax_locales', labelWidth: 0,
|
||||||
labelRight: 'Impuestos locales, calcular antes del descuento'},
|
labelRight: 'Impuestos locales, calcular antes del descuento'},
|
||||||
|
{view: 'checkbox', id: 'chk_config_tax_decimals', labelWidth: 0,
|
||||||
|
labelRight: 'Calcular impuestos con 4 decimales'},
|
||||||
|
{view: 'checkbox', id: 'chk_config_price_with_taxes_in_invoice', labelWidth: 0,
|
||||||
|
labelRight: 'Precio incluye impuestos'},
|
||||||
]},
|
]},
|
||||||
{maxHeight: 20},
|
{maxHeight: 20},
|
||||||
{template: 'Ayudas varias', type: 'section'},
|
{template: 'Ayudas varias', type: 'section'},
|
||||||
|
|
Loading…
Reference in New Issue