forked from elmau/empresa-libre
commit
94240f2356
|
@ -1191,7 +1191,10 @@ class LIBO(object):
|
|||
options = {'FilterName': 'calc_pdf_Export'}
|
||||
path_pdf = get_path_temp('.pdf')
|
||||
self._template.storeToURL(self._path_url(path_pdf), self._set_properties(options))
|
||||
self._template.close(True)
|
||||
try:
|
||||
self._template.close(True)
|
||||
except:
|
||||
pass
|
||||
data = self._read(path_pdf)
|
||||
_kill(path_ods)
|
||||
_kill(path_pdf)
|
||||
|
|
|
@ -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})
|
||||
|
|
|
@ -345,7 +345,7 @@ var grid_details_cols = [
|
|||
{id: "valor_unitario", header:{text: 'Valor Unitario', css: 'center'},
|
||||
width: 100, format: format_currency, css: 'right', editor: 'text'},
|
||||
{id: 'descuento', header:{text: 'Descuento', css: 'center'},
|
||||
width: 80, format: format_currency, css: 'right', editor: 'text'},
|
||||
width: 100, format: format_currency, css: 'right', editor: 'text'},
|
||||
{id: 'precio_final', hidden: true, header: 'precio_final', width: 80,
|
||||
format: webix.i18n.priceFormat, css: 'right'},
|
||||
{id: "importe", header:{text: 'Importe', css: 'center'}, width: 150,
|
||||
|
|
Loading…
Reference in New Issue