Buscar claves SAT

This commit is contained in:
Mauricio Baeza 2017-11-14 20:38:20 -06:00
parent a6cbe97f40
commit 7cf5e86391
4 changed files with 58 additions and 6 deletions

View File

@ -166,7 +166,7 @@ def get_con(rfc=''):
def get_sat_key(table, key):
con = sqlite3.connect(DB_SAT)
cursor = con.cursor()
sql = 'SELECT key, description FROM {} WHERE key=?'.format(table)
sql = 'SELECT key, name FROM {} WHERE key=?'.format(table)
cursor.execute(sql, (key,))
data = cursor.fetchone()
cursor.close()
@ -189,7 +189,26 @@ def get_sat_unidades(key):
cursor.close()
con.close()
if data is None:
return {'ok': False, 'text': 'No se encontró la unidad'}
return ()
data = [dict(r) for r in data]
return tuple(data)
def get_sat_productos(key):
con = sqlite3.connect(DB_SAT)
con.row_factory = sqlite3.Row
cursor = con.cursor()
filtro = '%{}%'.format(key)
sql = "SELECT * FROM productos WHERE key LIKE ? OR name LIKE ?"
cursor.execute(sql, [filtro, filtro])
data = cursor.fetchall()
cursor.close()
con.close()
if data is None:
return ()
data = [dict(r) for r in data]
return tuple(data)

View File

@ -121,6 +121,9 @@ class StorageEngine(object):
def _get_satunidades(self, values):
return main.get_sat_unidades(values['key'])
def _get_satproductos(self, values):
return main.get_sat_productos(values['key'])
def _get_series(self, values):
return main.Folios.get_all()

View File

@ -2703,6 +2703,9 @@ def get_sat_key(key):
def get_sat_unidades(key):
return util.get_sat_unidades(key)
def get_sat_productos(key):
return util.get_sat_productos(key)
def test_correo(values):
server = {

View File

@ -35,10 +35,10 @@ var grid_products = {
}
var suggest_categories = {
view: "datasuggest",
type: "tree",
view: 'datasuggest',
type: 'tree',
width: 400,
body: { data: [] },
body: {data: []},
}
@ -63,6 +63,32 @@ var grid_product_taxes = {
}
var suggest_sat_producto = {
view: 'gridsuggest',
id: 'grid_producto_found',
name: 'grid_producto_found',
body: {
autoConfig: false,
scroll: true,
autoheight: false,
header: true,
yCount: 10,
columns: [
{id: 'id', hidden: true},
{id: 'key', adjust: 'data', header: 'Clave SAT'},
{id: 'name', header: 'Producto', width: 750},
],
dataFeed:function(text){
if (text.length > 3){
this.load('/values/satproductos?key=' + text)
}else{
this.hide()
}
}
}
}
var controls_generals = [
{view: 'checkbox', id: 'es_activo_producto', name: 'es_activo_producto',
label: 'Activo: ', value: true,
@ -75,7 +101,8 @@ var controls_generals = [
{view: 'checkbox', id: 'chk_automatica', label: 'Automática',
labelPosition: 'top', value: true, maxWidth: 80},
{view: 'search', id: 'clave_sat', name: 'clave_sat', label: 'Clave SAT',
labelPosition: 'top', required: true, placeholder: 'Buscar clave...'},
labelPosition: 'top', required: true, suggest: suggest_sat_producto,
placeholder: 'Al menos 4 caracteres...'},
]},
{cols: [
{view: 'text', id: 'codigo_barras', name: 'codigo_barras',