Fix - redondeo en retenciones
This commit is contained in:
parent
cb6e4e21cf
commit
88085bfa06
|
@ -744,75 +744,6 @@ function search_client_id_key_press(code, e){
|
|||
}
|
||||
|
||||
|
||||
function calculate_taxes(){
|
||||
var tmp = null
|
||||
table_totals.clear()
|
||||
var subtotal = 0
|
||||
var total_iva = 0
|
||||
var id = 2
|
||||
var grid_totals = $$('grid_totals')
|
||||
|
||||
grid_totals.clearAll()
|
||||
grid_totals.add({id: 1, concepto: 'SubTotal', importe: 0})
|
||||
|
||||
grid.eachRow(function(row){
|
||||
var product = grid.getItem(row)
|
||||
subtotal += parseFloat(product.importe)
|
||||
query = table_pt.chain().find({'product': product.id}).data()
|
||||
for(var tax of query){
|
||||
tmp = table_totals.findOne({'tax': tax.tax})
|
||||
if(tmp === null){
|
||||
table_totals.insert(
|
||||
{'tax': tax.tax, 'importe': parseFloat(product.importe)})
|
||||
tmp = table_totals.findOne({'tax': tax.tax})
|
||||
}else{
|
||||
tmp.importe += parseFloat(product.importe)
|
||||
table_totals.update(tmp)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
var tax = null
|
||||
var tipo = 'Traslado '
|
||||
var concepto = ''
|
||||
var total_tax = 0
|
||||
query = table_totals.chain().data()
|
||||
for(var t of query){
|
||||
tax = table_taxes.findOne({'id': t.tax})
|
||||
if(tax.tipo == 'E' || tax.tipo == 'R'){
|
||||
continue
|
||||
}
|
||||
concepto = tipo + tax.name + ' (' + tax.tasa + ')'
|
||||
total_tax = (tax.tasa * t.importe).round(DECIMALES)
|
||||
grid_totals.add({id: id, concepto: concepto, importe: total_tax})
|
||||
id += 1
|
||||
if(tax.name == 'IVA'){
|
||||
total_iva += total_tax
|
||||
}
|
||||
}
|
||||
|
||||
tipo = 'Retención '
|
||||
for(var t of query){
|
||||
tax = table_taxes.findOne({'id': t.tax})
|
||||
if(tax.tipo == 'E' || tax.tipo == 'T'){
|
||||
continue
|
||||
}
|
||||
concepto = tipo + tax.name + ' (' + tax.tasa + ')'
|
||||
if(tax.tasa == (2/3).round(6)){
|
||||
total_tax = (tax.tasa * total_iva * -1).round(DECIMALES)
|
||||
concepto = tipo + tax.name + ' (2/3)'
|
||||
}else{
|
||||
total_tax = (tax.tasa * t.importe * -1).round(DECIMALES)
|
||||
}
|
||||
grid_totals.add({id: id, concepto: concepto, importe: total_tax})
|
||||
id += 1
|
||||
}
|
||||
|
||||
var row = {importe: subtotal}
|
||||
grid_totals.updateItem(1, row)
|
||||
}
|
||||
|
||||
|
||||
function calcular_impuestos(){
|
||||
var tmp = null
|
||||
var subtotal = 0
|
||||
|
@ -849,9 +780,9 @@ function calcular_impuestos(){
|
|||
base = import2
|
||||
}
|
||||
|
||||
if(impuesto.tipo == 'R'){
|
||||
base = (base * -1).round(DECIMALES)
|
||||
}
|
||||
//~ if(impuesto.tipo == 'R'){
|
||||
//~ base = (base * -1).round(DECIMALES)
|
||||
//~ }
|
||||
|
||||
if(cfg_invoice.tax_decimals){
|
||||
impuesto_producto = (impuesto.tasa * base).round(DECIMALES_TAX)
|
||||
|
@ -863,6 +794,11 @@ function calcular_impuestos(){
|
|||
impuesto_producto = Math.trunc(impuesto.tasa * base * 100) / 100
|
||||
}
|
||||
|
||||
if(impuesto.tipo == 'R'){
|
||||
//~ base = (base * -1).round(DECIMALES)
|
||||
impuesto_producto = (impuesto_producto * -1).round(DECIMALES)
|
||||
}
|
||||
|
||||
tmp = table_totals.findOne({'tax': tax.tax})
|
||||
if(tmp === null){
|
||||
table_totals.insert({'tax': tax.tax, 'importe': impuesto_producto})
|
||||
|
|
Loading…
Reference in New Issue