Soporte para pedimentos

This commit is contained in:
Mauricio Baeza 2018-01-08 09:40:35 -06:00
parent f5b34eec5b
commit 6de21e75bd
7 changed files with 61 additions and 9 deletions

View File

@ -204,6 +204,7 @@ class CFDI(object):
if 'complemento' in row:
complemento = row.pop('complemento')
cuenta_predial = row.pop('CuentaPredial', '')
pedimento = row.pop('Pedimento', '')
taxes = {}
if 'impuestos' in row:
@ -227,13 +228,17 @@ class CFDI(object):
ET.SubElement(
retenciones, '{}:Retencion'.format(self._pre), retencion)
if 'InformacionAduanera' in row:
for field in fields:
if field in row['InformacionAduanera']:
attributes[field] = row['InformacionAduanera'][field]
if attributes:
node_name = '{}:InformacionAduanera'.format(self._pre)
ET.SubElement(concepto, node_name, attributes)
# ~ if 'InformacionAduanera' in row:
# ~ for field in fields:
# ~ if field in row['InformacionAduanera']:
# ~ attributes[field] = row['InformacionAduanera'][field]
# ~ if attributes:
# ~ node_name = '{}:InformacionAduanera'.format(self._pre)
# ~ ET.SubElement(concepto, node_name, attributes)
if pedimento:
attributes = {'NumeroPedimento': pedimento}
node_name = '{}:InformacionAduanera'.format(self._pre)
ET.SubElement(concepto, node_name, attributes)
if cuenta_predial:
attributes = {'Numero': cuenta_predial}

View File

@ -156,6 +156,7 @@ def config_timbrar():
'cfdi_metodo_pago': Configuracion.get_bool('chk_config_ocultar_metodo_pago'),
'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'),
}
return conf
@ -238,6 +239,7 @@ class Configuracion(BaseModel):
'chk_config_ocultar_condiciones_pago',
'chk_config_send_zip',
'chk_config_open_pdf',
'chk_config_show_pedimento',
'chk_config_anticipo',
'chk_config_cuenta_predial',
'chk_config_codigo_barras',
@ -2853,6 +2855,7 @@ class Facturas(BaseModel):
locales_retenciones = 0
for product in products:
# ~ print (product)
id_product = product.pop('id')
p = Productos.get(Productos.id==id_product)
@ -3073,6 +3076,9 @@ class Facturas(BaseModel):
if row.cuenta_predial:
concepto['CuentaPredial'] = row.cuenta_predial
if row.pedimento:
concepto['Pedimento'] = row.pedimento
taxes = {}
traslados = []
retenciones = []

View File

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

@ -158,6 +158,9 @@ function default_config(){
$$('tv_invoice').getTabbar().showOption('INE')
}
cfg_invoice['open_pdf'] = values.cfdi_open_pdf
if(values.cfdi_show_pedimento){
$$('grid_details').showColumn('pedimento')
}
})
}
@ -881,7 +884,7 @@ function search_product_id_key_press(code, e){
function grid_details_before_edit_start(id){
var columns = ['', 'descripcion', 'cantidad', 'valor_unitario', 'descuento']
var columns = ['', 'descripcion', 'pedimento','cantidad', 'valor_unitario', 'descuento']
if(!columns.indexOf(id.column)){
return !this.getItem(id.row)[id.column]
}
@ -912,6 +915,24 @@ function grid_details_before_edit_stop(state, editor){
return true
}
if(editor.column == 'pedimento'){
state.value = state.value.trim()
if(state.value.length > 21){
msg = 'El Pedimento tiene más de 21 caracteres, será '
msg += 'rechazado por el SAT. Edita estalo hasta que ya '
msg += 'no veas este mensaje de error. <BR>'
msg += '<BR>Caracteres: ' + state.value.length
msg_error(msg)
}
if(state.value){
if(!validate_pedimento(state.value)){
msg = 'El formato del Pedimento es erroneo, será rechazado por el SAT'
msg_error(msg)
}
}
return true
}
if(editor.column == 'cantidad'){
var cantidad = parseFloat(state.value)
if(isNaN(cantidad)){

View File

@ -345,4 +345,20 @@ function get_forma_pago(control){
var values = data.json()
$$(control).getList().parse(values)
})
}
}
function validate_regexp(value, pattern){
re = new RegExp(pattern, 'i');
if(value.match(re)){
return true
}else{
return false
}
}
function validate_pedimento(value){
var pattern = '[0-9]{2} [0-9]{2} [0-9]{4} [0-9]{7}'
return validate_regexp(value, pattern)
}

View File

@ -507,6 +507,8 @@ var options_admin_otros = [
labelRight: 'Enviar factura en ZIP'},
{view: 'checkbox', id: 'chk_config_open_pdf', labelWidth: 0,
labelRight: 'Abrir PDF al timbrar'},
{view: 'checkbox', id: 'chk_config_show_pedimento', labelWidth: 0,
labelRight: 'Mostrar Pedimento'},
]},
{maxHeight: 20},
{template: 'Ayudas varias', type: 'section'},

View File

@ -279,6 +279,7 @@ var grid_details_cols = [
{id: "clave_sat", hidden: true},
{id: "descripcion", header:{text: 'Descripción', css: 'center'},
fillspace: true, editor: 'text'},
{id: "pedimento", header: 'Pedimento', editor: 'text', hidden: true},
{id: "unidad", header:{text: 'Unidad', css: 'center'}, width: 100},
{id: 'cantidad', header: {text: 'Cantidad', css: 'center'}, width: 100,
format: webix.i18n.numberFormat, css: 'right', editor: 'text'},