forked from elmau/empresa-libre
commit
57dce9670b
|
@ -20,6 +20,7 @@ import uuid
|
||||||
import zipfile
|
import zipfile
|
||||||
|
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
|
from math import trunc
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from xml.etree import ElementTree as ET
|
from xml.etree import ElementTree as ET
|
||||||
from xml.dom.minidom import parseString
|
from xml.dom.minidom import parseString
|
||||||
|
@ -3405,3 +3406,8 @@ def get_timbres(rfc, token):
|
||||||
return result.json()
|
return result.json()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
|
|
||||||
|
def truncate(value):
|
||||||
|
return trunc(value * 100) / 100
|
||||||
|
|
||||||
|
|
|
@ -246,6 +246,7 @@ def config_timbrar():
|
||||||
'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'),
|
'cfdi_with_taxes': Configuracion.get_bool('chk_config_price_with_taxes_in_invoice'),
|
||||||
'cfdi_add_same_product': Configuracion.get_bool('chk_config_add_same_product'),
|
'cfdi_add_same_product': Configuracion.get_bool('chk_config_add_same_product'),
|
||||||
|
'cfdi_tax_locales_truncate': Configuracion.get_bool('chk_config_tax_locales_truncate'),
|
||||||
}
|
}
|
||||||
|
|
||||||
return conf
|
return conf
|
||||||
|
@ -334,6 +335,7 @@ class Configuracion(BaseModel):
|
||||||
'chk_config_tax_decimals',
|
'chk_config_tax_decimals',
|
||||||
'chk_config_price_with_taxes_in_invoice',
|
'chk_config_price_with_taxes_in_invoice',
|
||||||
'chk_config_add_same_product',
|
'chk_config_add_same_product',
|
||||||
|
'chk_config_tax_locales_truncate',
|
||||||
'chk_config_anticipo',
|
'chk_config_anticipo',
|
||||||
'chk_config_cuenta_predial',
|
'chk_config_cuenta_predial',
|
||||||
'chk_config_codigo_barras',
|
'chk_config_codigo_barras',
|
||||||
|
@ -3632,11 +3634,16 @@ class Facturas(BaseModel):
|
||||||
rows = tuple(Facturas
|
rows = tuple(Facturas
|
||||||
.select(Facturas.id, Facturas.serie, Facturas.folio, Facturas.uuid,
|
.select(Facturas.id, Facturas.serie, Facturas.folio, Facturas.uuid,
|
||||||
Facturas.fecha, Facturas.tipo_comprobante, Facturas.estatus,
|
Facturas.fecha, Facturas.tipo_comprobante, Facturas.estatus,
|
||||||
|
case(Facturas.pagada, (
|
||||||
|
(True, 'Si'),
|
||||||
|
(False, 'No'),
|
||||||
|
)).alias('paid'),
|
||||||
Facturas.total_mn, Socios.nombre.alias('cliente'))
|
Facturas.total_mn, Socios.nombre.alias('cliente'))
|
||||||
.where(filters)
|
.where(filters)
|
||||||
.join(Socios)
|
.join(Socios)
|
||||||
.switch(Facturas).dicts()
|
.switch(Facturas).dicts()
|
||||||
)
|
)
|
||||||
|
|
||||||
return {'ok': True, 'rows': rows}
|
return {'ok': True, 'rows': rows}
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -3673,6 +3680,7 @@ class Facturas(BaseModel):
|
||||||
|
|
||||||
def _calculate_totals(self, invoice, products, tipo_comprobante):
|
def _calculate_totals(self, invoice, products, tipo_comprobante):
|
||||||
tax_locales = Configuracion.get_bool('chk_config_tax_locales')
|
tax_locales = Configuracion.get_bool('chk_config_tax_locales')
|
||||||
|
tax_locales_truncate = Configuracion.get_bool('chk_config_tax_locales_truncate')
|
||||||
tax_decimals = Configuracion.get_bool('chk_config_tax_decimals')
|
tax_decimals = Configuracion.get_bool('chk_config_tax_decimals')
|
||||||
subtotal = 0
|
subtotal = 0
|
||||||
descuento_cfdi = 0
|
descuento_cfdi = 0
|
||||||
|
@ -3732,6 +3740,9 @@ class Facturas(BaseModel):
|
||||||
else:
|
else:
|
||||||
impuesto_producto = round(float(tax.tasa) * base, DECIMALES)
|
impuesto_producto = round(float(tax.tasa) * base, DECIMALES)
|
||||||
|
|
||||||
|
if tax.key == '000' and tax_locales_truncate:
|
||||||
|
impuesto_producto = util.truncate(float(tax.tasa) * base)
|
||||||
|
|
||||||
if tax.tipo == 'T' and tax.key != '000':
|
if tax.tipo == 'T' and tax.key != '000':
|
||||||
total_trasladados = (total_trasladados or 0) + impuesto_producto
|
total_trasladados = (total_trasladados or 0) + impuesto_producto
|
||||||
elif tax.tipo == 'R' and tax.key != '000':
|
elif tax.tipo == 'R' and tax.key != '000':
|
||||||
|
@ -4674,6 +4685,7 @@ class PreFacturas(BaseModel):
|
||||||
def _calculate_totals(self, invoice, products):
|
def _calculate_totals(self, invoice, products):
|
||||||
tax_locales = Configuracion.get_bool('chk_config_tax_locales')
|
tax_locales = Configuracion.get_bool('chk_config_tax_locales')
|
||||||
tax_decimals = Configuracion.get_bool('chk_config_tax_decimals')
|
tax_decimals = Configuracion.get_bool('chk_config_tax_decimals')
|
||||||
|
tax_locales_truncate = Configuracion.get_bool('chk_config_tax_locales_truncate')
|
||||||
subtotal = 0
|
subtotal = 0
|
||||||
descuento_cfdi = 0
|
descuento_cfdi = 0
|
||||||
totals_tax = {}
|
totals_tax = {}
|
||||||
|
@ -4724,6 +4736,9 @@ class PreFacturas(BaseModel):
|
||||||
else:
|
else:
|
||||||
impuesto_producto = round(float(tax.tasa) * base, DECIMALES)
|
impuesto_producto = round(float(tax.tasa) * base, DECIMALES)
|
||||||
|
|
||||||
|
if tax.key == '000' and tax_locales_truncate:
|
||||||
|
impuesto_producto = util.truncate(float(tax.tasa) * base)
|
||||||
|
|
||||||
if tax.tipo == 'T' and tax.key != '000':
|
if tax.tipo == 'T' and tax.key != '000':
|
||||||
total_trasladados = (total_trasladados or 0) + impuesto_producto
|
total_trasladados = (total_trasladados or 0) + impuesto_producto
|
||||||
elif tax.tipo == 'R' and tax.key != '000':
|
elif tax.tipo == 'R' and tax.key != '000':
|
||||||
|
|
|
@ -65,6 +65,7 @@ var controllers = {
|
||||||
$$('chk_config_tax_decimals').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_price_with_taxes_in_invoice').attachEvent('onItemClick', chk_config_item_click)
|
||||||
$$('chk_config_add_same_product').attachEvent('onItemClick', chk_config_item_click)
|
$$('chk_config_add_same_product').attachEvent('onItemClick', chk_config_item_click)
|
||||||
|
$$('chk_config_tax_locales_truncate').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)
|
||||||
|
|
|
@ -171,6 +171,7 @@ function default_config(){
|
||||||
cfg_invoice['tax_decimals'] = values.cfdi_tax_decimals
|
cfg_invoice['tax_decimals'] = values.cfdi_tax_decimals
|
||||||
cfg_invoice['with_taxes'] = values.cfdi_with_taxes
|
cfg_invoice['with_taxes'] = values.cfdi_with_taxes
|
||||||
cfg_invoice['add_same_product'] = values.cfdi_add_same_product
|
cfg_invoice['add_same_product'] = values.cfdi_add_same_product
|
||||||
|
cfg_invoice['tax_locales_truncate'] = values.cfdi_tax_locales_truncate
|
||||||
if(values.cfdi_show_pedimento){
|
if(values.cfdi_show_pedimento){
|
||||||
$$('grid_details').showColumn('pedimento')
|
$$('grid_details').showColumn('pedimento')
|
||||||
}
|
}
|
||||||
|
@ -851,6 +852,11 @@ function calcular_impuestos(){
|
||||||
}else{
|
}else{
|
||||||
impuesto_producto = (impuesto.tasa * base).round(DECIMALES)
|
impuesto_producto = (impuesto.tasa * base).round(DECIMALES)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(cfg_invoice['tax_locales_truncate'] && impuesto.key == '000'){
|
||||||
|
impuesto_producto = Math.trunc(impuesto.tasa * base * 100) / 100
|
||||||
|
}
|
||||||
|
|
||||||
tmp = table_totals.findOne({'tax': tax.tax})
|
tmp = table_totals.findOne({'tax': tax.tax})
|
||||||
if(tmp === null){
|
if(tmp === null){
|
||||||
table_totals.insert({'tax': tax.tax, 'importe': impuesto_producto})
|
table_totals.insert({'tax': tax.tax, 'importe': impuesto_producto})
|
||||||
|
|
|
@ -602,6 +602,10 @@ var options_admin_otros = [
|
||||||
{view: 'checkbox', id: 'chk_config_add_same_product', labelWidth: 0,
|
{view: 'checkbox', id: 'chk_config_add_same_product', labelWidth: 0,
|
||||||
labelRight: 'Permitir agregar el mismo producto'},
|
labelRight: 'Permitir agregar el mismo producto'},
|
||||||
]},
|
]},
|
||||||
|
{cols: [{maxWidth: 15},
|
||||||
|
{view: 'checkbox', id: 'chk_config_tax_locales_truncate', labelWidth: 0,
|
||||||
|
labelRight: 'Impuestos locales, truncar valores'},
|
||||||
|
]},
|
||||||
{maxHeight: 20},
|
{maxHeight: 20},
|
||||||
{template: 'Ayudas varias', type: 'section'},
|
{template: 'Ayudas varias', type: 'section'},
|
||||||
{cols: [{maxWidth: 15},
|
{cols: [{maxWidth: 15},
|
||||||
|
|
|
@ -238,6 +238,8 @@ var grid_invoices_cols = [
|
||||||
adjust: 'header', sort: 'string'},
|
adjust: 'header', sort: 'string'},
|
||||||
{id: "estatus", header: ["Estatus", {content: "selectFilter"}],
|
{id: "estatus", header: ["Estatus", {content: "selectFilter"}],
|
||||||
adjust: "data", sort:"string"},
|
adjust: "data", sort:"string"},
|
||||||
|
{id: "paid", header: ["Pagada", {content: "selectFilter"}],
|
||||||
|
adjust: "data", sort:"string"},
|
||||||
{id: 'total_mn', header: ['Total M.N.', {content: 'numberFilter'}],
|
{id: 'total_mn', header: ['Total M.N.', {content: 'numberFilter'}],
|
||||||
width: 150, sort: 'int', format: webix.i18n.priceFormat, css: 'right',
|
width: 150, sort: 'int', format: webix.i18n.priceFormat, css: 'right',
|
||||||
footer: {content: 'summTimbrada', css: 'right'}},
|
footer: {content: 'summTimbrada', css: 'right'}},
|
||||||
|
@ -319,7 +321,7 @@ var grid_details = {
|
||||||
|
|
||||||
var grid_totals_cols = [
|
var grid_totals_cols = [
|
||||||
{id: 'id', header: 'ID', hidden: true},
|
{id: 'id', header: 'ID', hidden: true},
|
||||||
{id: 'concepto', header: 'Concepto', width: 200,
|
{id: 'concepto', header: 'Concepto', width: 250,
|
||||||
footer: {text: 'TOTAL', css:'right_footer'}, css:'right'},
|
footer: {text: 'TOTAL', css:'right_footer'}, css:'right'},
|
||||||
{id: 'importe', header: 'Importe', width: 150,
|
{id: 'importe', header: 'Importe', width: 150,
|
||||||
footer: {content: 'summColumn', css:'right_footer'},
|
footer: {content: 'summColumn', css:'right_footer'},
|
||||||
|
@ -331,7 +333,7 @@ var grid_totals = {
|
||||||
view: 'datatable',
|
view: 'datatable',
|
||||||
id: 'grid_totals',
|
id: 'grid_totals',
|
||||||
select: false,
|
select: false,
|
||||||
width: 350,
|
width: 400,
|
||||||
header: false,
|
header: false,
|
||||||
footer: true,
|
footer: true,
|
||||||
autoheight: true,
|
autoheight: true,
|
||||||
|
|
Loading…
Reference in New Issue