Merge branch 'develop'

Soporte para truncar impuestos
This commit is contained in:
Mauricio Baeza 2018-05-23 23:44:38 -05:00
commit 57dce9670b
6 changed files with 36 additions and 2 deletions

View File

@ -20,6 +20,7 @@ import uuid
import zipfile
from io import BytesIO
from math import trunc
from pathlib import Path
from xml.etree import ElementTree as ET
from xml.dom.minidom import parseString
@ -3405,3 +3406,8 @@ def get_timbres(rfc, token):
return result.json()
except Exception as e:
return ''
def truncate(value):
return trunc(value * 100) / 100

View File

@ -246,6 +246,7 @@ def config_timbrar():
'cfdi_tax_decimals': Configuracion.get_bool('chk_config_tax_decimals'),
'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_tax_locales_truncate': Configuracion.get_bool('chk_config_tax_locales_truncate'),
}
return conf
@ -334,6 +335,7 @@ class Configuracion(BaseModel):
'chk_config_tax_decimals',
'chk_config_price_with_taxes_in_invoice',
'chk_config_add_same_product',
'chk_config_tax_locales_truncate',
'chk_config_anticipo',
'chk_config_cuenta_predial',
'chk_config_codigo_barras',
@ -3632,11 +3634,16 @@ class Facturas(BaseModel):
rows = tuple(Facturas
.select(Facturas.id, Facturas.serie, Facturas.folio, Facturas.uuid,
Facturas.fecha, Facturas.tipo_comprobante, Facturas.estatus,
case(Facturas.pagada, (
(True, 'Si'),
(False, 'No'),
)).alias('paid'),
Facturas.total_mn, Socios.nombre.alias('cliente'))
.where(filters)
.join(Socios)
.switch(Facturas).dicts()
)
return {'ok': True, 'rows': rows}
@classmethod
@ -3673,6 +3680,7 @@ class Facturas(BaseModel):
def _calculate_totals(self, invoice, products, tipo_comprobante):
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')
subtotal = 0
descuento_cfdi = 0
@ -3732,6 +3740,9 @@ class Facturas(BaseModel):
else:
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':
total_trasladados = (total_trasladados or 0) + impuesto_producto
elif tax.tipo == 'R' and tax.key != '000':
@ -4674,6 +4685,7 @@ class PreFacturas(BaseModel):
def _calculate_totals(self, invoice, products):
tax_locales = Configuracion.get_bool('chk_config_tax_locales')
tax_decimals = Configuracion.get_bool('chk_config_tax_decimals')
tax_locales_truncate = Configuracion.get_bool('chk_config_tax_locales_truncate')
subtotal = 0
descuento_cfdi = 0
totals_tax = {}
@ -4724,6 +4736,9 @@ class PreFacturas(BaseModel):
else:
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':
total_trasladados = (total_trasladados or 0) + impuesto_producto
elif tax.tipo == 'R' and tax.key != '000':

View File

@ -65,6 +65,7 @@ var controllers = {
$$('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_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_ine').attachEvent('onItemClick', chk_config_item_click)
$$('chk_config_edu').attachEvent('onItemClick', chk_config_item_click)

View File

@ -171,6 +171,7 @@ function default_config(){
cfg_invoice['tax_decimals'] = values.cfdi_tax_decimals
cfg_invoice['with_taxes'] = values.cfdi_with_taxes
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){
$$('grid_details').showColumn('pedimento')
}
@ -851,6 +852,11 @@ function calcular_impuestos(){
}else{
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})
if(tmp === null){
table_totals.insert({'tax': tax.tax, 'importe': impuesto_producto})

View File

@ -602,6 +602,10 @@ var options_admin_otros = [
{view: 'checkbox', id: 'chk_config_add_same_product', labelWidth: 0,
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},
{template: 'Ayudas varias', type: 'section'},
{cols: [{maxWidth: 15},

View File

@ -238,6 +238,8 @@ var grid_invoices_cols = [
adjust: 'header', sort: 'string'},
{id: "estatus", header: ["Estatus", {content: "selectFilter"}],
adjust: "data", sort:"string"},
{id: "paid", header: ["Pagada", {content: "selectFilter"}],
adjust: "data", sort:"string"},
{id: 'total_mn', header: ['Total M.N.', {content: 'numberFilter'}],
width: 150, sort: 'int', format: webix.i18n.priceFormat, css: 'right',
footer: {content: 'summTimbrada', css: 'right'}},
@ -319,7 +321,7 @@ var grid_details = {
var grid_totals_cols = [
{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'},
{id: 'importe', header: 'Importe', width: 150,
footer: {content: 'summColumn', css:'right_footer'},
@ -331,7 +333,7 @@ var grid_totals = {
view: 'datatable',
id: 'grid_totals',
select: false,
width: 350,
width: 400,
header: false,
footer: true,
autoheight: true,