Calculo de impuestos locales antes del descuento

This commit is contained in:
Mauricio Baeza 2018-01-18 15:12:33 -06:00
parent 1cc7d1f1b8
commit aa66bc47dc
4 changed files with 21 additions and 2 deletions

View File

@ -160,6 +160,7 @@ def config_timbrar():
'cfdi_condicion_pago': Configuracion.get_bool('chk_config_ocultar_condiciones_pago'),
'cfdi_open_pdf': Configuracion.get_bool('chk_config_open_pdf'),
'cfdi_show_pedimento': Configuracion.get_bool('chk_config_show_pedimento'),
'cfdi_tax_locales': Configuracion.get_bool('chk_config_tax_locales'),
}
return conf
@ -244,6 +245,7 @@ class Configuracion(BaseModel):
'chk_config_send_zip',
'chk_config_open_pdf',
'chk_config_show_pedimento',
'chk_config_tax_locales',
'chk_config_anticipo',
'chk_config_cuenta_predial',
'chk_config_codigo_barras',
@ -2912,6 +2914,7 @@ class Facturas(BaseModel):
return inicio
def _calculate_totals(self, invoice, products):
tax_locales = Configuracion.get_bool('chk_config_tax_locales')
subtotal = 0
descuento_cfdi = 0
totals_tax = {}
@ -2953,6 +2956,8 @@ class Facturas(BaseModel):
base = product['importe'] - product['descuento']
for tax in p.impuestos:
if tax_locales and tax.tipo == 'R' and tax.key == '000':
base = product['importe']
impuesto_producto = round(float(tax.tasa) * base, DECIMALES)
if tax.tipo == 'T' and tax.key != '000':
total_trasladados = (total_trasladados or 0) + impuesto_producto

View File

@ -58,6 +58,7 @@ var controllers = {
$$('chk_config_send_zip').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_tax_locales').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_edu').attachEvent('onItemClick', chk_config_item_click)

View File

@ -161,6 +161,7 @@ function default_config(){
$$('tv_invoice').getTabbar().showOption('INE')
}
cfg_invoice['open_pdf'] = values.cfdi_open_pdf
cfg_invoice['tax_locales'] = values.cfdi_tax_locales
if(values.cfdi_show_pedimento){
$$('grid_details').showColumn('pedimento')
}
@ -773,6 +774,9 @@ function calcular_impuestos(){
grid.eachRow(function(row){
var product = grid.getItem(row)
var valor_unitario = parseFloat(product.valor_unitario)
var cantidad = parseFloat(product.cantidad)
var import2 = (valor_unitario * cantidad).round(DECIMALES)
var importe = parseFloat(product.importe)
subtotal += importe
query = table_pt.chain().find({'product': product.id}).data()
@ -783,9 +787,14 @@ function calcular_impuestos(){
}
var base = importe
if(impuesto.tipo == 'R'){
base = (importe * -1).round(DECIMALES)
if(cfg_invoice['tax_locales'] && impuesto.key == '000'){
base = import2
}
if(impuesto.tipo == 'R'){
base = (base * -1).round(DECIMALES)
}
impuesto_producto = (impuesto.tasa * base).round(DECIMALES)
tmp = table_totals.findOne({'tax': tax.tax})

View File

@ -510,6 +510,10 @@ var options_admin_otros = [
{view: 'checkbox', id: 'chk_config_show_pedimento', labelWidth: 0,
labelRight: 'Mostrar Pedimento'},
]},
{cols: [{maxWidth: 15},
{view: 'checkbox', id: 'chk_config_tax_locales', labelWidth: 0,
labelRight: 'Impuestos locales, calcular antes del descuento'},
]},
{maxHeight: 20},
{template: 'Ayudas varias', type: 'section'},
{cols: [{maxWidth: 15},