Agregar monedas
This commit is contained in:
parent
1997db32b0
commit
db6743745b
|
@ -125,6 +125,8 @@ class AppValues(object):
|
|||
req.context['result'] = self._db.send_email(values, session)
|
||||
elif table == 'enviarprefac':
|
||||
req.context['result'] = self._db.enviar_prefac(values)
|
||||
elif table == 'addmoneda':
|
||||
req.context['result'] = self._db.add_moneda(values)
|
||||
elif table == 'addunidad':
|
||||
req.context['result'] = self._db.add_unidad(values)
|
||||
elif table == 'addimpuesto':
|
||||
|
|
|
@ -173,6 +173,25 @@ def get_sat_key(table, key):
|
|||
return {'ok': True, 'text': data[1]}
|
||||
|
||||
|
||||
def get_sat_monedas(key):
|
||||
con = sqlite3.connect(DB_SAT)
|
||||
con.row_factory = sqlite3.Row
|
||||
cursor = con.cursor()
|
||||
|
||||
filtro = '%{}%'.format(key)
|
||||
sql = "SELECT * FROM monedas 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)
|
||||
|
||||
|
||||
def get_sat_unidades(key):
|
||||
con = sqlite3.connect(DB_SAT)
|
||||
con.row_factory = sqlite3.Row
|
||||
|
|
|
@ -104,6 +104,9 @@ class StorageEngine(object):
|
|||
def _get_unidades(self, values):
|
||||
return main.SATUnidades.get_activos()
|
||||
|
||||
def add_moneda(self, values):
|
||||
return main.SATMonedas.add(values)
|
||||
|
||||
def add_unidad(self, values):
|
||||
return main.SATUnidades.add(values)
|
||||
|
||||
|
@ -161,6 +164,9 @@ class StorageEngine(object):
|
|||
def _get_satkey(self, values):
|
||||
return main.get_sat_key(values['key'])
|
||||
|
||||
def _get_satmonedas(self, values):
|
||||
return main.get_sat_monedas(values['key'])
|
||||
|
||||
def _get_satunidades(self, values):
|
||||
return main.get_sat_unidades(values['key'])
|
||||
|
||||
|
|
|
@ -940,6 +940,14 @@ class SATMonedas(BaseModel):
|
|||
def __str__(self):
|
||||
return 'Moneda: ({}) {}'.format(self.key, self.name)
|
||||
|
||||
@classmethod
|
||||
def add(self, values):
|
||||
try:
|
||||
SATMonedas.create(**values)
|
||||
return {'ok': True}
|
||||
except:
|
||||
return {'ok': False}
|
||||
|
||||
@classmethod
|
||||
def get_(self):
|
||||
rows = SATMonedas.select().dicts()
|
||||
|
@ -3901,9 +3909,14 @@ def get_sat_key(key):
|
|||
return util.get_sat_key('productos', key)
|
||||
|
||||
|
||||
def get_sat_monedas(key):
|
||||
return util.get_sat_monedas(key)
|
||||
|
||||
|
||||
def get_sat_unidades(key):
|
||||
return util.get_sat_unidades(key)
|
||||
|
||||
|
||||
def get_sat_productos(key):
|
||||
return util.get_sat_productos(key)
|
||||
|
||||
|
|
BIN
source/db/sat.db
BIN
source/db/sat.db
Binary file not shown.
|
@ -34,6 +34,7 @@ var controllers = {
|
|||
$$('grid_admin_unidades').attachEvent('onCheck', grid_admin_unidades_on_check)
|
||||
$$('grid_admin_formasdepago').attachEvent('onCheck', grid_admin_formasdepago_on_check)
|
||||
$$('grid_unidad_found').attachEvent('onValueSuggest', grid_unidad_found_click)
|
||||
$$('grid_moneda_found').attachEvent('onValueSuggest', grid_moneda_found_click)
|
||||
$$('cmd_agregar_impuesto').attachEvent('onItemClick', cmd_agregar_impuesto_click)
|
||||
//~ Usuarios
|
||||
$$('cmd_usuario_agregar').attachEvent('onItemClick', cmd_usuario_agregar_click)
|
||||
|
@ -1131,6 +1132,44 @@ function cmd_emisor_agregar_cuenta_click(){
|
|||
}
|
||||
|
||||
|
||||
function agregar_nueva_moneda(obj){
|
||||
var grid = $$('grid_admin_monedas')
|
||||
var values = {key: obj.key, name: obj.name}
|
||||
|
||||
webix.ajax().post('/values/addmoneda', values, {
|
||||
error: function(text, data, xhr) {
|
||||
webix.message({type: 'error', text: 'Error al agregar'})
|
||||
},
|
||||
success: function(text, data, xhr){
|
||||
var values = data.json()
|
||||
if (values.ok){
|
||||
grid.add(obj)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
function grid_moneda_found_click(obj){
|
||||
msg = '¿Estás seguro de agregar la siguiente moneda?<BR><BR>'
|
||||
msg += '(' + obj.key + ') ' + obj.name
|
||||
|
||||
webix.confirm({
|
||||
title: 'Agregar Moneda',
|
||||
ok: 'Si',
|
||||
cancel: 'No',
|
||||
type: 'confirm-error',
|
||||
text: msg,
|
||||
callback:function(result){
|
||||
if(result){
|
||||
agregar_nueva_moneda(obj)
|
||||
}
|
||||
}
|
||||
})
|
||||
$$('buscar_nueva_moneda').setValue('')
|
||||
}
|
||||
|
||||
|
||||
function agregar_nueva_unidad(obj){
|
||||
var grid = $$('grid_admin_unidades')
|
||||
var values = {key: obj.key, name: obj.name}
|
||||
|
|
|
@ -695,11 +695,49 @@ var sat_impuestos = [
|
|||
{}]
|
||||
|
||||
|
||||
var suggest_sat_moneda = {
|
||||
view: 'gridsuggest',
|
||||
id: 'grid_moneda_found',
|
||||
name: 'grid_moneda_found',
|
||||
body: {
|
||||
autoConfig: false,
|
||||
scroll:true,
|
||||
autoheight:false,
|
||||
header: true,
|
||||
yCount: 10,
|
||||
columns: [
|
||||
{id: 'id', hidden: true},
|
||||
{id: 'key', adjust: 'data', header: 'Clave'},
|
||||
{id: 'name', adjust: 'data', header: 'Moneda'},
|
||||
],
|
||||
dataFeed:function(text){
|
||||
if (text.length > 2){
|
||||
this.load('/values/satmonedas?key=' + text)
|
||||
}else{
|
||||
this.hide()
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
var buscar_nueva_moneda = {
|
||||
view: 'search',
|
||||
id: 'buscar_nueva_moneda',
|
||||
label: 'Buscar Moneda en el catálogo del SAT',
|
||||
labelPosition: 'top',
|
||||
suggest: suggest_sat_moneda,
|
||||
placeholder: 'Por clave o moneda. Captura al menos tres letras',
|
||||
}
|
||||
|
||||
|
||||
var msg_moneda = 'Activa las monedas que uses. La predeterminada se muestra primero'
|
||||
var sat_monedas = [
|
||||
{maxHeight: 20},
|
||||
{cols: [{maxWidth: 15}, {view: 'label', label: msg_moneda}, {}]},
|
||||
{maxHeight: 20},
|
||||
{cols: [{maxWidth: 15}, buscar_nueva_moneda, {}]},
|
||||
{maxHeight: 20},
|
||||
{cols: [{maxWidth: 15}, grid_admin_monedas, {}]},
|
||||
{}]
|
||||
|
||||
|
|
Loading…
Reference in New Issue