diff --git a/source/app/controllers/cfdi_xml.py b/source/app/controllers/cfdi_xml.py
index b66c579..67096e7 100644
--- a/source/app/controllers/cfdi_xml.py
+++ b/source/app/controllers/cfdi_xml.py
@@ -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}
diff --git a/source/app/models/main.py b/source/app/models/main.py
index 7e082cd..223ab6c 100644
--- a/source/app/models/main.py
+++ b/source/app/models/main.py
@@ -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 = []
diff --git a/source/static/js/controller/admin.js b/source/static/js/controller/admin.js
index ebe9190..26b7096 100644
--- a/source/static/js/controller/admin.js
+++ b/source/static/js/controller/admin.js
@@ -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)
diff --git a/source/static/js/controller/invoices.js b/source/static/js/controller/invoices.js
index a4d4e1b..2b3ea4a 100644
--- a/source/static/js/controller/invoices.js
+++ b/source/static/js/controller/invoices.js
@@ -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.
'
+ msg += '
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)){
diff --git a/source/static/js/controller/util.js b/source/static/js/controller/util.js
index 06667f0..8c31ce7 100644
--- a/source/static/js/controller/util.js
+++ b/source/static/js/controller/util.js
@@ -345,4 +345,20 @@ function get_forma_pago(control){
var values = data.json()
$$(control).getList().parse(values)
})
-}
\ No newline at end of file
+}
+
+
+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)
+}
diff --git a/source/static/js/ui/admin.js b/source/static/js/ui/admin.js
index 7780c70..d9bc6cf 100644
--- a/source/static/js/ui/admin.js
+++ b/source/static/js/ui/admin.js
@@ -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'},
diff --git a/source/static/js/ui/invoices.js b/source/static/js/ui/invoices.js
index d9cb39e..961573e 100644
--- a/source/static/js/ui/invoices.js
+++ b/source/static/js/ui/invoices.js
@@ -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'},