SAT formas de pago en Admin
This commit is contained in:
parent
e2008525f1
commit
c0d1c41401
|
@ -112,6 +112,9 @@ class StorageEngine(object):
|
|||
def _get_allunidades(self, values):
|
||||
return main.SATUnidades.get_()
|
||||
|
||||
def _get_allformasdepago(self, values):
|
||||
return main.SATFormaPago.get_()
|
||||
|
||||
def _get_taxupdate(self, values):
|
||||
return main.SATImpuestos.actualizar(values)
|
||||
|
||||
|
@ -124,6 +127,9 @@ class StorageEngine(object):
|
|||
def _get_unidadupdate(self, values):
|
||||
return main.SATUnidades.actualizar(values)
|
||||
|
||||
def _get_formasdepagoupdate(self, values):
|
||||
return main.SATFormaPago.actualizar(values)
|
||||
|
||||
def _get_emisorcuentasbanco(self, values):
|
||||
return main.CuentasBanco.emisor()
|
||||
|
||||
|
|
|
@ -695,6 +695,11 @@ class SATFormaPago(BaseModel):
|
|||
def __str__(self):
|
||||
return 'Forma de pago: ({}) {}'.format(self.key, self.name)
|
||||
|
||||
@classmethod
|
||||
def get_(self):
|
||||
rows = SATFormaPago.select().dicts()
|
||||
return tuple(rows)
|
||||
|
||||
@classmethod
|
||||
def get_by_key(cls, key):
|
||||
return SATFormaPago.get(SATFormaPago.key==key)
|
||||
|
@ -711,6 +716,27 @@ class SATFormaPago(BaseModel):
|
|||
)
|
||||
return tuple(rows)
|
||||
|
||||
@classmethod
|
||||
def actualizar(self, values):
|
||||
id = int(values['id'])
|
||||
if values['field'] == 'activo':
|
||||
v = {'0': False, '1': True}
|
||||
q = (SATFormaPago
|
||||
.update(**{'activo': v[values['value']]})
|
||||
.where(SATFormaPago.id==id))
|
||||
result = bool(q.execute())
|
||||
elif values['field'] == 'default':
|
||||
q = SATFormaPago.update(**{'default': False})
|
||||
q.execute()
|
||||
|
||||
v = {'false': False, 'true': True}
|
||||
q = (SATFormaPago
|
||||
.update(**{'default': v[values['value']]})
|
||||
.where(SATFormaPago.id==id))
|
||||
result = bool(q.execute())
|
||||
|
||||
return {'ok': result}
|
||||
|
||||
|
||||
class SATAduanas(BaseModel):
|
||||
key = TextField(unique=True, index=True)
|
||||
|
|
|
@ -32,6 +32,7 @@ var controllers = {
|
|||
$$('grid_admin_monedas').attachEvent('onCheck', grid_admin_monedas_on_check)
|
||||
$$('grid_admin_bancos').attachEvent('onCheck', grid_admin_bancos_on_check)
|
||||
$$('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)
|
||||
$$('cmd_agregar_impuesto').attachEvent('onItemClick', cmd_agregar_impuesto_click)
|
||||
//~ Opciones
|
||||
|
@ -259,6 +260,7 @@ function get_admin_impuestos(){
|
|||
$$('grid_admin_taxes').clearAll()
|
||||
$$('grid_admin_taxes').parse(values, 'json')
|
||||
})
|
||||
$$('tab_sat').setValue('Impuestos')
|
||||
}
|
||||
|
||||
|
||||
|
@ -289,6 +291,15 @@ function get_admin_unidades(){
|
|||
}
|
||||
|
||||
|
||||
function get_admin_formasdepago(){
|
||||
webix.ajax().sync().get('/values/allformasdepago', function(text, data){
|
||||
var values = data.json()
|
||||
$$('grid_admin_formasdepago').clearAll()
|
||||
$$('grid_admin_formasdepago').parse(values, 'json')
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
function get_config_values(opt){
|
||||
if(opt == undefined){
|
||||
return
|
||||
|
@ -906,6 +917,8 @@ function tab_sat_change(nv, ov){
|
|||
get_admin_bancos()
|
||||
}else if(nv == 'Unidades'){
|
||||
get_admin_unidades()
|
||||
}else if(nv == 'Formas de Pago'){
|
||||
get_admin_formasdepago()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -974,6 +987,22 @@ function grid_admin_unidades_on_check(row, column, state){
|
|||
}
|
||||
|
||||
|
||||
function grid_admin_formasdepago_on_check(row, column, state){
|
||||
|
||||
var values = {
|
||||
id: row,
|
||||
field: column,
|
||||
value: state,
|
||||
}
|
||||
webix.ajax().get('/values/formasdepagoupdate', values, {
|
||||
error: function(text, data, xhr) {
|
||||
},
|
||||
success: function(text, data, xhr) {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
function emisor_cuenta_saldo_inicial_change(new_value, old_value){
|
||||
if(!isFinite(new_value)){
|
||||
this.config.value = old_value
|
||||
|
|
|
@ -515,7 +515,7 @@ var grid_admin_taxes = {
|
|||
view: 'datatable',
|
||||
id: 'grid_admin_taxes',
|
||||
select: 'cell',
|
||||
multiselect: true,
|
||||
//~ multiselect: true,
|
||||
adjust: true,
|
||||
autoheight: true,
|
||||
autowidth: true,
|
||||
|
@ -528,7 +528,7 @@ var grid_admin_monedas = {
|
|||
view: 'datatable',
|
||||
id: 'grid_admin_monedas',
|
||||
select: 'cell',
|
||||
multiselect: true,
|
||||
//~ multiselect: true,
|
||||
adjust: true,
|
||||
autoheight: true,
|
||||
autowidth: true,
|
||||
|
@ -541,7 +541,7 @@ var grid_admin_bancos = {
|
|||
view: 'datatable',
|
||||
id: 'grid_admin_bancos',
|
||||
select: 'cell',
|
||||
multiselect: true,
|
||||
//~ multiselect: true,
|
||||
adjust: true,
|
||||
autowidth: true,
|
||||
headermenu: true,
|
||||
|
@ -554,7 +554,7 @@ var grid_admin_unidades = {
|
|||
view: 'datatable',
|
||||
id: 'grid_admin_unidades',
|
||||
select: 'cell',
|
||||
multiselect: true,
|
||||
//~ multiselect: true,
|
||||
adjust: true,
|
||||
autowidth: true,
|
||||
autoheight: true,
|
||||
|
@ -564,6 +564,31 @@ var grid_admin_unidades = {
|
|||
}
|
||||
|
||||
|
||||
var grid_admin_formasdepago_cols = [
|
||||
{id: 'id', header: 'ID', hidden: true},
|
||||
{id: 'key', header: 'Clave'},
|
||||
{id: 'name', header: 'Nombre', adjust: 'data'},
|
||||
{id: 'activo', header: 'Activa', template: '{common.checkbox()}',
|
||||
editor: 'checkbox'},
|
||||
{id: 'default', header: 'Predeterminada', template: '{common.radio()}',
|
||||
adjust: 'header'},
|
||||
]
|
||||
|
||||
|
||||
var grid_admin_formasdepago = {
|
||||
view: 'datatable',
|
||||
id: 'grid_admin_formasdepago',
|
||||
select: 'cell',
|
||||
//~ multiselect: true,
|
||||
adjust: true,
|
||||
autowidth: true,
|
||||
//~ autoheight: true,
|
||||
headermenu: true,
|
||||
footer: true,
|
||||
columns: grid_admin_formasdepago_cols,
|
||||
}
|
||||
|
||||
|
||||
var admin_sat_impuestos = {cols: [{maxWidth: 15},
|
||||
{view: 'richselect', id: 'lst_admin_impuestos', label: 'Impuesto', options:
|
||||
['ISR', 'IVA', 'IEPS', 'ISH', 'INSPECCION DE OBRA', 'ICIC', 'CEDULAR'],
|
||||
|
@ -653,22 +678,33 @@ var sat_unidades = [
|
|||
]
|
||||
|
||||
|
||||
var msg_formasdepago = 'Activar las formas de pago.'
|
||||
var sat_formasdepago = [
|
||||
{maxHeight: 20},
|
||||
{cols: [{maxWidth: 15}, {view: 'label', label: msg_formasdepago}, {}]},
|
||||
{maxHeight: 20},
|
||||
{cols: [{maxWidth: 15}, grid_admin_formasdepago, {}]},
|
||||
{maxHeight: 20},
|
||||
]
|
||||
|
||||
|
||||
var tab_sat = {
|
||||
view: 'tabview',
|
||||
id: 'tab_sat',
|
||||
multiview: true,
|
||||
tabbar: {options: [
|
||||
'Impuestos',
|
||||
'Monedas',
|
||||
'Bancos',
|
||||
'Unidades'
|
||||
]},
|
||||
//~ tabbar: {options: [
|
||||
//~ 'Impuestos',
|
||||
//~ 'Monedas',
|
||||
//~ 'Bancos',
|
||||
//~ 'Unidades'
|
||||
//~ ]},
|
||||
animate: true,
|
||||
cells: [
|
||||
{id: 'Impuestos', rows: sat_impuestos},
|
||||
{id: 'Monedas', rows: sat_monedas},
|
||||
{id: 'Bancos', rows: sat_bancos},
|
||||
{id: 'Unidades', rows: sat_unidades},
|
||||
{id: 'Formas de Pago', rows: sat_formasdepago},
|
||||
],
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue