Soporte para pedimentos
This commit is contained in:
commit
21bf7451cc
|
@ -204,6 +204,7 @@ class CFDI(object):
|
||||||
if 'complemento' in row:
|
if 'complemento' in row:
|
||||||
complemento = row.pop('complemento')
|
complemento = row.pop('complemento')
|
||||||
cuenta_predial = row.pop('CuentaPredial', '')
|
cuenta_predial = row.pop('CuentaPredial', '')
|
||||||
|
pedimento = row.pop('Pedimento', '')
|
||||||
|
|
||||||
taxes = {}
|
taxes = {}
|
||||||
if 'impuestos' in row:
|
if 'impuestos' in row:
|
||||||
|
@ -227,13 +228,17 @@ class CFDI(object):
|
||||||
ET.SubElement(
|
ET.SubElement(
|
||||||
retenciones, '{}:Retencion'.format(self._pre), retencion)
|
retenciones, '{}:Retencion'.format(self._pre), retencion)
|
||||||
|
|
||||||
if 'InformacionAduanera' in row:
|
# ~ if 'InformacionAduanera' in row:
|
||||||
for field in fields:
|
# ~ for field in fields:
|
||||||
if field in row['InformacionAduanera']:
|
# ~ if field in row['InformacionAduanera']:
|
||||||
attributes[field] = row['InformacionAduanera'][field]
|
# ~ attributes[field] = row['InformacionAduanera'][field]
|
||||||
if attributes:
|
# ~ if attributes:
|
||||||
node_name = '{}:InformacionAduanera'.format(self._pre)
|
# ~ node_name = '{}:InformacionAduanera'.format(self._pre)
|
||||||
ET.SubElement(concepto, node_name, attributes)
|
# ~ 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:
|
if cuenta_predial:
|
||||||
attributes = {'Numero': cuenta_predial}
|
attributes = {'Numero': cuenta_predial}
|
||||||
|
|
|
@ -156,6 +156,7 @@ def config_timbrar():
|
||||||
'cfdi_metodo_pago': Configuracion.get_bool('chk_config_ocultar_metodo_pago'),
|
'cfdi_metodo_pago': Configuracion.get_bool('chk_config_ocultar_metodo_pago'),
|
||||||
'cfdi_condicion_pago': Configuracion.get_bool('chk_config_ocultar_condiciones_pago'),
|
'cfdi_condicion_pago': Configuracion.get_bool('chk_config_ocultar_condiciones_pago'),
|
||||||
'cfdi_open_pdf': Configuracion.get_bool('chk_config_open_pdf'),
|
'cfdi_open_pdf': Configuracion.get_bool('chk_config_open_pdf'),
|
||||||
|
'cfdi_show_pedimento': Configuracion.get_bool('chk_config_show_pedimento'),
|
||||||
}
|
}
|
||||||
|
|
||||||
return conf
|
return conf
|
||||||
|
@ -203,6 +204,7 @@ class Configuracion(BaseModel):
|
||||||
'chk_config_cuenta_predial',
|
'chk_config_cuenta_predial',
|
||||||
'chk_config_codigo_barras',
|
'chk_config_codigo_barras',
|
||||||
'chk_config_precio_con_impuestos',
|
'chk_config_precio_con_impuestos',
|
||||||
|
'chk_llevar_inventario',
|
||||||
)
|
)
|
||||||
data = (Configuracion
|
data = (Configuracion
|
||||||
.select()
|
.select()
|
||||||
|
@ -237,10 +239,12 @@ class Configuracion(BaseModel):
|
||||||
'chk_config_ocultar_condiciones_pago',
|
'chk_config_ocultar_condiciones_pago',
|
||||||
'chk_config_send_zip',
|
'chk_config_send_zip',
|
||||||
'chk_config_open_pdf',
|
'chk_config_open_pdf',
|
||||||
|
'chk_config_show_pedimento',
|
||||||
'chk_config_anticipo',
|
'chk_config_anticipo',
|
||||||
'chk_config_cuenta_predial',
|
'chk_config_cuenta_predial',
|
||||||
'chk_config_codigo_barras',
|
'chk_config_codigo_barras',
|
||||||
'chk_config_precio_con_impuestos',
|
'chk_config_precio_con_impuestos',
|
||||||
|
'chk_llevar_inventario',
|
||||||
'chk_config_ine',
|
'chk_config_ine',
|
||||||
'chk_config_edu',
|
'chk_config_edu',
|
||||||
'chk_usar_punto_de_venta',
|
'chk_usar_punto_de_venta',
|
||||||
|
@ -2195,6 +2199,9 @@ class Productos(BaseModel):
|
||||||
Productos.unidad,
|
Productos.unidad,
|
||||||
Productos.valor_unitario,
|
Productos.valor_unitario,
|
||||||
Productos.cuenta_predial,
|
Productos.cuenta_predial,
|
||||||
|
Productos.inventario,
|
||||||
|
Productos.existencia,
|
||||||
|
Productos.minimo,
|
||||||
)
|
)
|
||||||
.where(Productos.id==id).dicts()[0]
|
.where(Productos.id==id).dicts()[0]
|
||||||
)
|
)
|
||||||
|
@ -2848,6 +2855,7 @@ class Facturas(BaseModel):
|
||||||
locales_retenciones = 0
|
locales_retenciones = 0
|
||||||
|
|
||||||
for product in products:
|
for product in products:
|
||||||
|
# ~ print (product)
|
||||||
id_product = product.pop('id')
|
id_product = product.pop('id')
|
||||||
p = Productos.get(Productos.id==id_product)
|
p = Productos.get(Productos.id==id_product)
|
||||||
|
|
||||||
|
@ -3068,6 +3076,9 @@ class Facturas(BaseModel):
|
||||||
if row.cuenta_predial:
|
if row.cuenta_predial:
|
||||||
concepto['CuentaPredial'] = row.cuenta_predial
|
concepto['CuentaPredial'] = row.cuenta_predial
|
||||||
|
|
||||||
|
if row.pedimento:
|
||||||
|
concepto['Pedimento'] = row.pedimento
|
||||||
|
|
||||||
taxes = {}
|
taxes = {}
|
||||||
traslados = []
|
traslados = []
|
||||||
retenciones = []
|
retenciones = []
|
||||||
|
@ -4050,6 +4061,10 @@ class Tickets(BaseModel):
|
||||||
|
|
||||||
TicketsDetalle.create(**producto)
|
TicketsDetalle.create(**producto)
|
||||||
|
|
||||||
|
if p.inventario:
|
||||||
|
p.existencia -= Decimal(cantidad)
|
||||||
|
p.save()
|
||||||
|
|
||||||
base = producto['importe']
|
base = producto['importe']
|
||||||
for tax in p.impuestos:
|
for tax in p.impuestos:
|
||||||
impuesto_producto = round(float(tax.tasa) * base, DECIMALES)
|
impuesto_producto = round(float(tax.tasa) * base, DECIMALES)
|
||||||
|
@ -4292,13 +4307,24 @@ class Tickets(BaseModel):
|
||||||
data = {'ok': True, 'msg': msg, 'id': obj.id}
|
data = {'ok': True, 'msg': msg, 'id': obj.id}
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
def _update_inventory_if_cancel(self, id):
|
||||||
|
products = TicketsDetalle.select().where(TicketsDetalle.ticket==id)
|
||||||
|
for p in products:
|
||||||
|
if p.producto.inventario:
|
||||||
|
p.producto.existencia += p.cantidad
|
||||||
|
p.producto.save()
|
||||||
|
return
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def cancel(cls, values):
|
def cancel(cls, values):
|
||||||
id = int(values['id'])
|
id = int(values['id'])
|
||||||
msg = 'Ticket cancelado correctamente'
|
msg = 'Ticket cancelado correctamente'
|
||||||
u = {'cancelado': True, 'estatus': 'Cancelado'}
|
u = {'cancelado': True, 'estatus': 'Cancelado'}
|
||||||
obj = Tickets.update(**u).where(Tickets.id==id)
|
with database_proxy.atomic() as txn:
|
||||||
result = bool(obj.execute())
|
obj = Tickets.update(**u).where(Tickets.id==id)
|
||||||
|
result = bool(obj.execute())
|
||||||
|
if result:
|
||||||
|
cls._update_inventory_if_cancel(cls, id)
|
||||||
row = {'estatus': 'Cancelado'}
|
row = {'estatus': 'Cancelado'}
|
||||||
return {'ok': result, 'row': row, 'msg': msg}
|
return {'ok': result, 'row': row, 'msg': msg}
|
||||||
|
|
||||||
|
|
|
@ -55,12 +55,14 @@ var controllers = {
|
||||||
$$('chk_config_ocultar_condiciones_pago').attachEvent('onItemClick', chk_config_item_click)
|
$$('chk_config_ocultar_condiciones_pago').attachEvent('onItemClick', chk_config_item_click)
|
||||||
$$('chk_config_send_zip').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_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_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)
|
||||||
$$('chk_config_cuenta_predial').attachEvent('onItemClick', chk_config_item_click)
|
$$('chk_config_cuenta_predial').attachEvent('onItemClick', chk_config_item_click)
|
||||||
$$('chk_config_codigo_barras').attachEvent('onItemClick', chk_config_item_click)
|
$$('chk_config_codigo_barras').attachEvent('onItemClick', chk_config_item_click)
|
||||||
$$('chk_config_precio_con_impuestos').attachEvent('onItemClick', chk_config_item_click)
|
$$('chk_config_precio_con_impuestos').attachEvent('onItemClick', chk_config_item_click)
|
||||||
|
$$('chk_llevar_inventario').attachEvent('onItemClick', chk_config_item_click)
|
||||||
$$('chk_usar_punto_de_venta').attachEvent('onItemClick', chk_config_item_click)
|
$$('chk_usar_punto_de_venta').attachEvent('onItemClick', chk_config_item_click)
|
||||||
$$('chk_ticket_pdf_show').attachEvent('onItemClick', chk_config_item_click)
|
$$('chk_ticket_pdf_show').attachEvent('onItemClick', chk_config_item_click)
|
||||||
$$('chk_ticket_direct_print').attachEvent('onItemClick', chk_config_item_click)
|
$$('chk_ticket_direct_print').attachEvent('onItemClick', chk_config_item_click)
|
||||||
|
|
|
@ -158,6 +158,9 @@ function default_config(){
|
||||||
$$('tv_invoice').getTabbar().showOption('INE')
|
$$('tv_invoice').getTabbar().showOption('INE')
|
||||||
}
|
}
|
||||||
cfg_invoice['open_pdf'] = values.cfdi_open_pdf
|
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){
|
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)){
|
if(!columns.indexOf(id.column)){
|
||||||
return !this.getItem(id.row)[id.column]
|
return !this.getItem(id.row)[id.column]
|
||||||
}
|
}
|
||||||
|
@ -912,6 +915,24 @@ function grid_details_before_edit_stop(state, editor){
|
||||||
return true
|
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'){
|
if(editor.column == 'cantidad'){
|
||||||
var cantidad = parseFloat(state.value)
|
var cantidad = parseFloat(state.value)
|
||||||
if(isNaN(cantidad)){
|
if(isNaN(cantidad)){
|
||||||
|
|
|
@ -11,6 +11,7 @@ var products_controllers = {
|
||||||
$$("valor_unitario").attachEvent("onChange", valor_unitario_change)
|
$$("valor_unitario").attachEvent("onChange", valor_unitario_change)
|
||||||
$$('precio_con_impuestos').attachEvent('onChange', precio_con_impuestos_change)
|
$$('precio_con_impuestos').attachEvent('onChange', precio_con_impuestos_change)
|
||||||
$$('precio_con_impuestos').attachEvent('onTimedKeyPress', precio_con_impuestos_key_up);
|
$$('precio_con_impuestos').attachEvent('onTimedKeyPress', precio_con_impuestos_key_up);
|
||||||
|
$$("chk_inventario").attachEvent("onChange", chk_inventario_change)
|
||||||
$$('grid_products').attachEvent('onItemDblClick', cmd_edit_product_click)
|
$$('grid_products').attachEvent('onItemDblClick', cmd_edit_product_click)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,6 +29,9 @@ function configurar_productos(is_new){
|
||||||
show('cuenta_predial', values.chk_config_cuenta_predial)
|
show('cuenta_predial', values.chk_config_cuenta_predial)
|
||||||
show('codigo_barras', values.chk_config_codigo_barras)
|
show('codigo_barras', values.chk_config_codigo_barras)
|
||||||
show('precio_con_impuestos', values.chk_config_precio_con_impuestos)
|
show('precio_con_impuestos', values.chk_config_precio_con_impuestos)
|
||||||
|
show('chk_inventario', values.chk_llevar_inventario)
|
||||||
|
show('txt_existencia', values.chk_llevar_inventario)
|
||||||
|
show('txt_minimo', values.chk_llevar_inventario)
|
||||||
$$('unidad').setValue(values.default_unidad)
|
$$('unidad').setValue(values.default_unidad)
|
||||||
if(is_new){
|
if(is_new){
|
||||||
$$('grid_product_taxes').select(values.default_tax)
|
$$('grid_product_taxes').select(values.default_tax)
|
||||||
|
@ -228,6 +232,20 @@ function chk_automatica_change(new_value, old_value){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function chk_inventario_change(new_value, old_value){
|
||||||
|
var value = Boolean(new_value)
|
||||||
|
if(value){
|
||||||
|
$$('txt_existencia').enable()
|
||||||
|
$$('txt_minimo').enable()
|
||||||
|
}else{
|
||||||
|
$$('txt_existencia').disable()
|
||||||
|
$$('txt_minimo').disable()
|
||||||
|
$$('txt_existencia').setValue(0)
|
||||||
|
$$('txt_minimo').setValue(0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function get_new_key(){
|
function get_new_key(){
|
||||||
webix.ajax().get('/values/newkey', {
|
webix.ajax().get('/values/newkey', {
|
||||||
error: function(text, data, xhr) {
|
error: function(text, data, xhr) {
|
||||||
|
|
|
@ -346,3 +346,19 @@ function get_forma_pago(control){
|
||||||
$$(control).getList().parse(values)
|
$$(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)
|
||||||
|
}
|
||||||
|
|
|
@ -507,6 +507,8 @@ var options_admin_otros = [
|
||||||
labelRight: 'Enviar factura en ZIP'},
|
labelRight: 'Enviar factura en ZIP'},
|
||||||
{view: 'checkbox', id: 'chk_config_open_pdf', labelWidth: 0,
|
{view: 'checkbox', id: 'chk_config_open_pdf', labelWidth: 0,
|
||||||
labelRight: 'Abrir PDF al timbrar'},
|
labelRight: 'Abrir PDF al timbrar'},
|
||||||
|
{view: 'checkbox', id: 'chk_config_show_pedimento', labelWidth: 0,
|
||||||
|
labelRight: 'Mostrar Pedimento'},
|
||||||
]},
|
]},
|
||||||
{maxHeight: 20},
|
{maxHeight: 20},
|
||||||
{template: 'Ayudas varias', type: 'section'},
|
{template: 'Ayudas varias', type: 'section'},
|
||||||
|
@ -523,6 +525,8 @@ var options_admin_otros = [
|
||||||
labelRight: 'Mostrar código de barras'},
|
labelRight: 'Mostrar código de barras'},
|
||||||
{view: 'checkbox', id: 'chk_config_precio_con_impuestos', labelWidth: 0,
|
{view: 'checkbox', id: 'chk_config_precio_con_impuestos', labelWidth: 0,
|
||||||
labelRight: 'Mostrar precio con impuestos'},
|
labelRight: 'Mostrar precio con impuestos'},
|
||||||
|
{view: 'checkbox', id: 'chk_llevar_inventario', labelWidth: 0,
|
||||||
|
labelRight: 'Mostrar inventario'},
|
||||||
]},
|
]},
|
||||||
{maxHeight: 20},
|
{maxHeight: 20},
|
||||||
{template: 'Complementos', type: 'section'},
|
{template: 'Complementos', type: 'section'},
|
||||||
|
|
|
@ -279,6 +279,7 @@ var grid_details_cols = [
|
||||||
{id: "clave_sat", hidden: true},
|
{id: "clave_sat", hidden: true},
|
||||||
{id: "descripcion", header:{text: 'Descripción', css: 'center'},
|
{id: "descripcion", header:{text: 'Descripción', css: 'center'},
|
||||||
fillspace: true, editor: 'text'},
|
fillspace: true, editor: 'text'},
|
||||||
|
{id: "pedimento", header: 'Pedimento', editor: 'text', hidden: true},
|
||||||
{id: "unidad", header:{text: 'Unidad', css: 'center'}, width: 100},
|
{id: "unidad", header:{text: 'Unidad', css: 'center'}, width: 100},
|
||||||
{id: 'cantidad', header: {text: 'Cantidad', css: 'center'}, width: 100,
|
{id: 'cantidad', header: {text: 'Cantidad', css: 'center'}, width: 100,
|
||||||
format: webix.i18n.numberFormat, css: 'right', editor: 'text'},
|
format: webix.i18n.numberFormat, css: 'right', editor: 'text'},
|
||||||
|
|
|
@ -134,13 +134,14 @@ var controls_generals = [
|
||||||
invalidMessage: 'Captura un valor númerico', inputAlign: 'right'},
|
invalidMessage: 'Captura un valor númerico', inputAlign: 'right'},
|
||||||
{},]},
|
{},]},
|
||||||
{cols: [
|
{cols: [
|
||||||
{view: 'checkbox', id: 'inventario', name: 'inventario', hidden: true,
|
{view: 'checkbox', id: 'chk_inventario', name: 'inventario', hidden: true,
|
||||||
label: 'Inventario', labelAlign: 'right', labelWidth: 130},
|
label: 'Inventario', labelAlign: 'right', labelWidth: 130},
|
||||||
{view: 'counter', id: 'existencia', name: 'existencia', hidden: true,
|
{view: 'counter', id: 'txt_existencia', name: 'existencia',
|
||||||
label: 'Existencia', step: 5, value: 0, min: 0, disabled: true},
|
hidden: true, label: 'Existencia', step: 5, value: 0, min: 0,
|
||||||
{view: 'counter', id: 'minimo', name: 'minimo', hidden: true,
|
disabled: true},
|
||||||
|
{view: 'counter', id: 'txt_minimo', name: 'minimo', hidden: true,
|
||||||
label: 'Mínimo', step: 5, value: 0, min: 0, disabled: true},
|
label: 'Mínimo', step: 5, value: 0, min: 0, disabled: true},
|
||||||
{id: 'txt_col2'}]},
|
]},
|
||||||
{cols:[{view:'label', label:'Impuestos', width: 300, align:'center'}, {}]},
|
{cols:[{view:'label', label:'Impuestos', width: 300, align:'center'}, {}]},
|
||||||
{cols:[grid_product_taxes, {}]}
|
{cols:[grid_product_taxes, {}]}
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in New Issue