forked from elmau/empresa-libre
Configurar anticipo y donativo
This commit is contained in:
parent
9b430b882b
commit
364ac55b8b
|
@ -14,6 +14,9 @@ class StorageEngine(object):
|
||||||
def get_values(self, table, values=None):
|
def get_values(self, table, values=None):
|
||||||
return getattr(self, '_get_{}'.format(table))(values)
|
return getattr(self, '_get_{}'.format(table))(values)
|
||||||
|
|
||||||
|
def _get_configtimbrar(self, values):
|
||||||
|
return main.config_timbrar()
|
||||||
|
|
||||||
def _get_validartimbrar(self, values):
|
def _get_validartimbrar(self, values):
|
||||||
return main.validar_timbrar()
|
return main.validar_timbrar()
|
||||||
|
|
||||||
|
|
|
@ -102,6 +102,20 @@ def validar_timbrar():
|
||||||
return {'ok': True, 'msg': msg}
|
return {'ok': True, 'msg': msg}
|
||||||
|
|
||||||
|
|
||||||
|
def config_timbrar():
|
||||||
|
try:
|
||||||
|
obj = Emisor.select()[0]
|
||||||
|
except IndexError:
|
||||||
|
return {'cfdi_donativo': False}
|
||||||
|
|
||||||
|
conf = {
|
||||||
|
'cfdi_anticipo': Configuracion.get_('chk_config_anticipo'),
|
||||||
|
'cfdi_donativo': obj.es_ong,
|
||||||
|
}
|
||||||
|
|
||||||
|
return conf
|
||||||
|
|
||||||
|
|
||||||
class Configuracion(BaseModel):
|
class Configuracion(BaseModel):
|
||||||
clave = TextField(unique=True)
|
clave = TextField(unique=True)
|
||||||
valor = TextField(default='')
|
valor = TextField(default='')
|
||||||
|
@ -143,6 +157,13 @@ class Configuracion(BaseModel):
|
||||||
.select()
|
.select()
|
||||||
.where(Configuracion.clave.in_(fields))
|
.where(Configuracion.clave.in_(fields))
|
||||||
)
|
)
|
||||||
|
elif keys['fields'] == 'configotros':
|
||||||
|
fields = (
|
||||||
|
'chk_config_anticipo',)
|
||||||
|
data = (Configuracion
|
||||||
|
.select()
|
||||||
|
.where(Configuracion.clave.in_(fields))
|
||||||
|
)
|
||||||
|
|
||||||
values = {r.clave: r.valor for r in data}
|
values = {r.clave: r.valor for r in data}
|
||||||
return values
|
return values
|
||||||
|
@ -151,6 +172,7 @@ class Configuracion(BaseModel):
|
||||||
def add(cls, values):
|
def add(cls, values):
|
||||||
try:
|
try:
|
||||||
for k, v in values.items():
|
for k, v in values.items():
|
||||||
|
print (k, v)
|
||||||
obj, created = Configuracion.get_or_create(clave=k)
|
obj, created = Configuracion.get_or_create(clave=k)
|
||||||
obj.valor = v
|
obj.valor = v
|
||||||
obj.save()
|
obj.save()
|
||||||
|
|
|
@ -39,6 +39,7 @@ var controllers = {
|
||||||
tb_options.attachEvent('onChange', tab_options_change)
|
tb_options.attachEvent('onChange', tab_options_change)
|
||||||
$$('txt_plantilla_factura_32').attachEvent('onItemClick', txt_plantilla_factura_32_click)
|
$$('txt_plantilla_factura_32').attachEvent('onItemClick', txt_plantilla_factura_32_click)
|
||||||
$$('txt_plantilla_factura_33').attachEvent('onItemClick', txt_plantilla_factura_33_click)
|
$$('txt_plantilla_factura_33').attachEvent('onItemClick', txt_plantilla_factura_33_click)
|
||||||
|
$$('chk_config_anticipo').attachEvent('onItemClick', chk_config_item_click)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -297,6 +298,7 @@ function get_config_values(opt){
|
||||||
},
|
},
|
||||||
success: function(text, data, xhr) {
|
success: function(text, data, xhr) {
|
||||||
var values = data.json()
|
var values = data.json()
|
||||||
|
showvar(values)
|
||||||
Object.keys(values).forEach(function(key){
|
Object.keys(values).forEach(function(key){
|
||||||
$$(key).setValue(values[key])
|
$$(key).setValue(values[key])
|
||||||
})
|
})
|
||||||
|
@ -808,6 +810,7 @@ function txt_plantilla_factura_32_click(e){
|
||||||
function tab_options_change(nv, ov){
|
function tab_options_change(nv, ov){
|
||||||
var cv = {
|
var cv = {
|
||||||
Plantillas: 'templates',
|
Plantillas: 'templates',
|
||||||
|
Otros: 'configotros',
|
||||||
}
|
}
|
||||||
get_config_values(cv[nv])
|
get_config_values(cv[nv])
|
||||||
}
|
}
|
||||||
|
@ -1185,3 +1188,23 @@ function cmd_emisor_eliminar_cuenta_click(){
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function chk_config_item_click(id, e){
|
||||||
|
var values = {}
|
||||||
|
values[id] = $$(id).getValue()
|
||||||
|
|
||||||
|
webix.ajax().sync().post('/config', values, {
|
||||||
|
error: function(text, data, xhr) {
|
||||||
|
msg = 'Error al guardar la configuración'
|
||||||
|
msg_error(msg)
|
||||||
|
},
|
||||||
|
success: function(text, data, xhr) {
|
||||||
|
var values = data.json();
|
||||||
|
if (!values.ok){
|
||||||
|
msg_error(values.msg)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -56,7 +56,6 @@ function get_monedas(){
|
||||||
$$('lst_moneda').setValue(pre.id)
|
$$('lst_moneda').setValue(pre.id)
|
||||||
if(values.length == 1){
|
if(values.length == 1){
|
||||||
$$('fs_moneda').hide()
|
$$('fs_moneda').hide()
|
||||||
//~ $$('fs_moneda').refresh()
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -77,7 +76,6 @@ function get_regimen_fiscal(){
|
||||||
$$('lst_regimen_fiscal').setValue(pre.id)
|
$$('lst_regimen_fiscal').setValue(pre.id)
|
||||||
if(values.length == 1){
|
if(values.length == 1){
|
||||||
$$('fs_regimen_fiscal').hide()
|
$$('fs_regimen_fiscal').hide()
|
||||||
//~ $$('fs_regimen_fiscal').refresh()
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -109,6 +107,13 @@ function default_config(){
|
||||||
$$('cmd_timbrar').enable()
|
$$('cmd_timbrar').enable()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
webix.ajax().sync().get('/values/configtimbrar', function(text, data){
|
||||||
|
var values = data.json()
|
||||||
|
show('chk_cfdi_anticipo', values.cfdi_anticipo)
|
||||||
|
show('chk_cfdi_donativo', values.cfdi_donativo)
|
||||||
|
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -808,7 +813,7 @@ function grid_details_header_click(id){
|
||||||
|
|
||||||
|
|
||||||
function cmd_refacturar_click(){
|
function cmd_refacturar_click(){
|
||||||
show('Refacturar')
|
showvar('Refacturar')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1014,7 +1019,7 @@ function cmd_invoice_sat_click(){
|
||||||
|
|
||||||
webix.ajax().get('/values/statussat', {id: row.id}, function(text, data){
|
webix.ajax().get('/values/statussat', {id: row.id}, function(text, data){
|
||||||
var values = data.json()
|
var values = data.json()
|
||||||
show(values)
|
showvar(values)
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,11 +33,23 @@ var months = [
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
function show(values){
|
function showvar(values){
|
||||||
webix.message(JSON.stringify(values, null, 2))
|
webix.message(JSON.stringify(values, null, 2))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function show(nombre, value){
|
||||||
|
if(value == '0'){
|
||||||
|
value = false
|
||||||
|
}
|
||||||
|
if(value){
|
||||||
|
$$(nombre).show()
|
||||||
|
}else{
|
||||||
|
$$(nombre).hide()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function msg_error(msg){
|
function msg_error(msg){
|
||||||
webix.message({type: 'error', text: msg})
|
webix.message({type: 'error', text: msg})
|
||||||
}
|
}
|
||||||
|
|
|
@ -430,6 +430,16 @@ var options_templates = [
|
||||||
{}]
|
{}]
|
||||||
|
|
||||||
|
|
||||||
|
var options_admin_otros = [
|
||||||
|
{maxHeight: 15},
|
||||||
|
{cols: [{maxWidth: 15},
|
||||||
|
{view: 'checkbox', id: 'chk_config_anticipo', labelWidth: 0,
|
||||||
|
labelRight: 'Ayuda para generar anticipos'},
|
||||||
|
{}]},
|
||||||
|
{maxHeight: 20},
|
||||||
|
{}]
|
||||||
|
|
||||||
|
|
||||||
var tab_options = {
|
var tab_options = {
|
||||||
view: 'tabview',
|
view: 'tabview',
|
||||||
id: 'tab_options',
|
id: 'tab_options',
|
||||||
|
@ -440,7 +450,7 @@ var tab_options = {
|
||||||
animate: true,
|
animate: true,
|
||||||
cells: [
|
cells: [
|
||||||
{id: 'Plantillas', rows: options_templates},
|
{id: 'Plantillas', rows: options_templates},
|
||||||
{id: 'Otros', rows: [{}]},
|
{id: 'Otros', rows: options_admin_otros},
|
||||||
{},
|
{},
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
|
@ -163,8 +163,11 @@ var toolbar_invoices_util = [
|
||||||
var toolbar_invoices_generate = {view: 'toolbar', elements: [{},
|
var toolbar_invoices_generate = {view: 'toolbar', elements: [{},
|
||||||
{view: 'button', id: 'cmd_cfdi_relacionados', label: 'CFDI Relacionados',
|
{view: 'button', id: 'cmd_cfdi_relacionados', label: 'CFDI Relacionados',
|
||||||
type: 'iconButton', autowidth: true, icon: 'file-o'},
|
type: 'iconButton', autowidth: true, icon: 'file-o'},
|
||||||
{view: 'checkbox', id: 'chk_cfdi_anticipo', label: 'Es Anticipo', width: 100},
|
{view: 'checkbox', id: 'chk_cfdi_anticipo', labelRight: 'Es Anticipo',
|
||||||
]}
|
labelWidth: 0, width: 100, hidden: true},
|
||||||
|
{view: 'checkbox', id: 'chk_cfdi_donativo', labelRight: 'Es Donativo',
|
||||||
|
labelWidth: 0, width: 100, hidden: true},
|
||||||
|
{}]}
|
||||||
|
|
||||||
|
|
||||||
var toolbar_invoices_filter = [
|
var toolbar_invoices_filter = [
|
||||||
|
|
Loading…
Reference in New Issue