forked from elmau/empresa-libre
Add sucursales
This commit is contained in:
parent
7062151e79
commit
348be949ac
|
@ -1,3 +1,8 @@
|
||||||
|
v 1.43.0 [00-Jun-2021]
|
||||||
|
----------------------
|
||||||
|
- Multialmacen
|
||||||
|
|
||||||
|
|
||||||
v 1.42.0 [24-May-2021]
|
v 1.42.0 [24-May-2021]
|
||||||
----------------------
|
----------------------
|
||||||
- Opción para que solo un admin pueda cancelar.
|
- Opción para que solo un admin pueda cancelar.
|
||||||
|
|
|
@ -648,3 +648,19 @@ class AppCert(object):
|
||||||
req.context['result'] = self._db.cert_post(values)
|
req.context['result'] = self._db.cert_post(values)
|
||||||
resp.status = falcon.HTTP_200
|
resp.status = falcon.HTTP_200
|
||||||
|
|
||||||
|
|
||||||
|
class AppSucursales(object):
|
||||||
|
|
||||||
|
def __init__(self, db):
|
||||||
|
self._db = db
|
||||||
|
|
||||||
|
def on_get(self, req, resp):
|
||||||
|
values = req.params
|
||||||
|
req.context['result'] = self._db.sucursales_get(values)
|
||||||
|
resp.status = falcon.HTTP_200
|
||||||
|
|
||||||
|
def on_post(self, req, resp):
|
||||||
|
values = req.params
|
||||||
|
req.context['result'] = self._db.sucursales_post(values)
|
||||||
|
resp.status = falcon.HTTP_200
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ from controllers.main import (AppEmpresas,
|
||||||
AppDocumentos, AppFiles, AppPreInvoices, AppCuentasBanco,
|
AppDocumentos, AppFiles, AppPreInvoices, AppCuentasBanco,
|
||||||
AppMovimientosBanco, AppTickets, AppStudents, AppEmployees, AppNomina,
|
AppMovimientosBanco, AppTickets, AppStudents, AppEmployees, AppNomina,
|
||||||
AppInvoicePay, AppCfdiPay, AppSATBancos, AppSociosCuentasBanco,
|
AppInvoicePay, AppCfdiPay, AppSATBancos, AppSociosCuentasBanco,
|
||||||
AppSATFormaPago, AppSATLeyendaFiscales, AppCert
|
AppSATFormaPago, AppSATLeyendaFiscales, AppCert, AppSucursales
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -63,6 +63,7 @@ api.add_route('/satformapago', AppSATFormaPago(db))
|
||||||
api.add_route('/socioscb', AppSociosCuentasBanco(db))
|
api.add_route('/socioscb', AppSociosCuentasBanco(db))
|
||||||
api.add_route('/leyendasfiscales', AppSATLeyendaFiscales(db))
|
api.add_route('/leyendasfiscales', AppSATLeyendaFiscales(db))
|
||||||
api.add_route('/cert', AppCert(db))
|
api.add_route('/cert', AppCert(db))
|
||||||
|
api.add_route('/sucursales', AppSucursales(db))
|
||||||
|
|
||||||
|
|
||||||
session_options = {
|
session_options = {
|
||||||
|
|
|
@ -472,6 +472,12 @@ class StorageEngine(object):
|
||||||
def cert_post(self, values):
|
def cert_post(self, values):
|
||||||
return main.Certificado.post(values)
|
return main.Certificado.post(values)
|
||||||
|
|
||||||
|
def sucursales_get(self, values):
|
||||||
|
return main.Sucursales.get_data(values)
|
||||||
|
|
||||||
|
def sucursales_post(self, values):
|
||||||
|
return main.Sucursales.post(values)
|
||||||
|
|
||||||
# Companies only in MV
|
# Companies only in MV
|
||||||
def _get_empresas(self, values):
|
def _get_empresas(self, values):
|
||||||
return main.companies_get()
|
return main.companies_get()
|
||||||
|
|
|
@ -545,6 +545,10 @@ class Configuracion(BaseModel):
|
||||||
data['pass'] = token
|
data['pass'] = token
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
def _get_admin_sucursales(cls, args):
|
||||||
|
rows = Folios.get_for_sucursales()
|
||||||
|
return rows
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_(cls, keys):
|
def get_(cls, keys):
|
||||||
if isinstance(keys, str):
|
if isinstance(keys, str):
|
||||||
|
@ -565,8 +569,10 @@ class Configuracion(BaseModel):
|
||||||
'admin_config_users',
|
'admin_config_users',
|
||||||
'pac_auth',
|
'pac_auth',
|
||||||
'auth_by_pac',
|
'auth_by_pac',
|
||||||
|
'admin_sucursales',
|
||||||
)
|
)
|
||||||
opt = keys['fields']
|
opt = keys['fields']
|
||||||
|
|
||||||
if opt in options:
|
if opt in options:
|
||||||
return getattr(cls, f'_get_{opt}')(cls, keys)
|
return getattr(cls, f'_get_{opt}')(cls, keys)
|
||||||
|
|
||||||
|
@ -806,6 +812,43 @@ class Sucursales(BaseModel):
|
||||||
class Meta:
|
class Meta:
|
||||||
order_by = ('nombre',)
|
order_by = ('nombre',)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _get_for_admin(cls, args):
|
||||||
|
rows = (Sucursales
|
||||||
|
.select(
|
||||||
|
Sucursales.id,
|
||||||
|
Sucursales.nombre.alias('name'),
|
||||||
|
Sucursales.serie_facturas.alias('serie_invoice'),
|
||||||
|
Sucursales.serie_tickets,
|
||||||
|
)
|
||||||
|
.dicts()
|
||||||
|
)
|
||||||
|
return tuple(rows)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_data(cls, values):
|
||||||
|
opt = values['opt']
|
||||||
|
return getattr(cls, f'_get_{opt}')(values)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _create(cls, args):
|
||||||
|
try:
|
||||||
|
values = utils.loads(args)
|
||||||
|
Sucursales.create(**values)
|
||||||
|
result = {'ok': True}
|
||||||
|
except Exception as e:
|
||||||
|
log.error(e)
|
||||||
|
msg = 'Ocurrio un error al agregar la sucursal'
|
||||||
|
result = {'ok': False, 'msg': msg}
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def post(cls, values):
|
||||||
|
opt = values['opt']
|
||||||
|
args = values['values']
|
||||||
|
return getattr(cls, f'_{opt}')(args)
|
||||||
|
|
||||||
|
|
||||||
class Roles(BaseModel):
|
class Roles(BaseModel):
|
||||||
nombre = TextField(default='')
|
nombre = TextField(default='')
|
||||||
|
@ -1275,6 +1318,18 @@ class Folios(BaseModel):
|
||||||
)
|
)
|
||||||
return tuple(rows)
|
return tuple(rows)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_for_sucursales(cls):
|
||||||
|
rows = (Folios
|
||||||
|
.select(
|
||||||
|
Folios.serie.alias('id'),
|
||||||
|
Folios.serie.alias('value'),
|
||||||
|
)
|
||||||
|
.where(Folios.usarcon == '')
|
||||||
|
.dicts()
|
||||||
|
)
|
||||||
|
return tuple(rows)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_(cls):
|
def get_(cls):
|
||||||
rows = (Folios
|
rows = (Folios
|
||||||
|
|
|
@ -42,7 +42,7 @@ except ImportError:
|
||||||
|
|
||||||
|
|
||||||
DEBUG = DEBUG
|
DEBUG = DEBUG
|
||||||
VERSION = '1.42.0'
|
VERSION = '1.43.0'
|
||||||
EMAIL_SUPPORT = ('soporte@empresalibre.mx',)
|
EMAIL_SUPPORT = ('soporte@empresalibre.mx',)
|
||||||
TITLE_APP = '{} v{}'.format(TITLE_APP, VERSION)
|
TITLE_APP = '{} v{}'.format(TITLE_APP, VERSION)
|
||||||
|
|
||||||
|
|
|
@ -144,14 +144,16 @@ var controllers = {
|
||||||
$$('lst_pac').attachEvent('onChange', lst_pac_on_change)
|
$$('lst_pac').attachEvent('onChange', lst_pac_on_change)
|
||||||
$$('cmd_save_pac').attachEvent('onItemClick', cmd_save_pac_click)
|
$$('cmd_save_pac').attachEvent('onItemClick', cmd_save_pac_click)
|
||||||
|
|
||||||
$$('cmd_subir_bdfl').attachEvent('onItemClick', cmd_subir_bdfl_click)
|
//~ $$('cmd_subir_bdfl').attachEvent('onItemClick', cmd_subir_bdfl_click)
|
||||||
$$('cmd_subir_cfdixml').attachEvent('onItemClick', cmd_subir_cfdixml_click)
|
$$('cmd_subir_cfdixml').attachEvent('onItemClick', cmd_subir_cfdixml_click)
|
||||||
$$('up_bdfl').attachEvent('onUploadComplete', up_bdfl_upload_complete)
|
//~ $$('up_bdfl').attachEvent('onUploadComplete', up_bdfl_upload_complete)
|
||||||
$$('up_cfdixml').attachEvent('onUploadComplete', up_cfdixml_upload_complete)
|
$$('up_cfdixml').attachEvent('onUploadComplete', up_cfdixml_upload_complete)
|
||||||
|
|
||||||
$$('grid_admin_bancos').attachEvent('onAfterEditStart', grid_admin_bancos_after_edit_start)
|
$$('grid_admin_bancos').attachEvent('onAfterEditStart', grid_admin_bancos_after_edit_start)
|
||||||
$$('grid_admin_bancos').attachEvent('onBeforeEditStop', grid_admin_bancos_before_edit_stop)
|
$$('grid_admin_bancos').attachEvent('onBeforeEditStop', grid_admin_bancos_before_edit_stop)
|
||||||
//~ $$('grid_admin_bancos').attachEvent('onAfterEditStop', grid_admin_bancos_after_edit_stop)
|
|
||||||
|
//~ Sucursales
|
||||||
|
$$('cmd_add_sucursal').attachEvent('onItemClick', cmd_add_sucursal_click)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -470,11 +472,33 @@ function set_config_templates(){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function set_config_admin_sucursales(){
|
||||||
|
webix.ajax().get('/config', {'fields': 'admin_sucursales'}, {
|
||||||
|
error: function(text, data, xhr) {
|
||||||
|
msg = 'Error al consultar'
|
||||||
|
msg_error(msg)
|
||||||
|
},
|
||||||
|
success: function(text, data, xhr) {
|
||||||
|
var values = data.json()
|
||||||
|
lst_parse2('lst_sucursal_add_invoice', values)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
get_admin_sucursales()
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function get_config_values(opt){
|
function get_config_values(opt){
|
||||||
if(opt == undefined){
|
if(opt == undefined){
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(opt == 'admin_sucursales'){
|
||||||
|
set_config_admin_sucursales()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if(opt == 'templates'){
|
if(opt == 'templates'){
|
||||||
set_config_templates()
|
set_config_templates()
|
||||||
}
|
}
|
||||||
|
@ -1230,6 +1254,7 @@ function tab_options_change(nv, ov){
|
||||||
tab_admin_products: 'admin_products',
|
tab_admin_products: 'admin_products',
|
||||||
tab_admin_complements: 'complements',
|
tab_admin_complements: 'complements',
|
||||||
tab_admin_otros: 'configotros',
|
tab_admin_otros: 'configotros',
|
||||||
|
tab_admin_sucursales: 'admin_sucursales',
|
||||||
}
|
}
|
||||||
get_config_values(cv[nv])
|
get_config_values(cv[nv])
|
||||||
}
|
}
|
||||||
|
@ -2739,3 +2764,107 @@ function validate_cert(values){
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function get_admin_sucursales(){
|
||||||
|
|
||||||
|
webix.ajax().get('/sucursales', {'opt': 'for_admin'}, {
|
||||||
|
error: function(text, data, xhr) {
|
||||||
|
msg = 'Error al consultar'
|
||||||
|
msg_error(msg)
|
||||||
|
},
|
||||||
|
success: function(text, data, xhr) {
|
||||||
|
var values = data.json()
|
||||||
|
grid_parse('grid_sucursales', values)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function cmd_add_sucursal_click(){
|
||||||
|
var form = $$('form_add_sucursal')
|
||||||
|
|
||||||
|
if (!form.validate()){
|
||||||
|
msg = 'Faltan datos o son inválidos'
|
||||||
|
msg_error(msg)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var values = form.getValues()
|
||||||
|
|
||||||
|
sucursal_name = values.sucursal_add_name.trim()
|
||||||
|
sucursal_invoice = values.sucursal_add_invoice
|
||||||
|
sucursal_ticket = values.sucursal_add_ticket.trim()
|
||||||
|
|
||||||
|
if(!sucursal_name){
|
||||||
|
msg = 'El campo Nombre de la sucursal no puede estar vacío'
|
||||||
|
msg_error(msg)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!sucursal_invoice){
|
||||||
|
msg = 'Selecciona un valor para Serie Factura'
|
||||||
|
msg_error(msg)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!sucursal_ticket){
|
||||||
|
msg = 'El campo Serie Ticket no puede estar vacío'
|
||||||
|
msg_error(msg)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var rows = $$('grid_sucursales').data.getRange()
|
||||||
|
for (i = 0; i < rows.length; i++) {
|
||||||
|
if(rows[i]['name'] == sucursal_name){
|
||||||
|
msg = 'El nombre de sucursal ya existe'
|
||||||
|
msg_error(msg)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var values = {
|
||||||
|
nombre: sucursal_name,
|
||||||
|
serie_facturas: sucursal_invoice,
|
||||||
|
serie_tickets: sucursal_ticket,
|
||||||
|
}
|
||||||
|
var data = {
|
||||||
|
opt: 'create',
|
||||||
|
values: values,
|
||||||
|
}
|
||||||
|
var clean = {
|
||||||
|
txt_sucursal_add_name: '',
|
||||||
|
lst_sucursal_add_invoice: '',
|
||||||
|
txt_sucursal_add_ticket: '',
|
||||||
|
}
|
||||||
|
|
||||||
|
msg = 'Datos correctos.<BR><BR>¿Estás seguro de agregar la nueva sucursal?'
|
||||||
|
webix.confirm({
|
||||||
|
title: 'Agregar Sucursal',
|
||||||
|
ok: 'Si',
|
||||||
|
cancel: 'No',
|
||||||
|
type: 'confirm-error',
|
||||||
|
text: msg,
|
||||||
|
callback:function(result){
|
||||||
|
if(result){
|
||||||
|
webix.ajax().post('/sucursales', data, {
|
||||||
|
error:function(text, data, XmlHttpRequest){
|
||||||
|
msg = 'Ocurrio un error, consulta a soporte técnico'
|
||||||
|
msg_error(msg)
|
||||||
|
},
|
||||||
|
success:function(text, data, XmlHttpRequest){
|
||||||
|
var values = data.json()
|
||||||
|
if(values.ok){
|
||||||
|
get_admin_sucursales()
|
||||||
|
form.setValues(clean)
|
||||||
|
msg_ok('Sucursal agregada correctamente')
|
||||||
|
}else{
|
||||||
|
msg_error(values.msg)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
@ -603,6 +603,12 @@ function lst_parse(lst, values){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function lst_parse2(lst_name, values){
|
||||||
|
obj = $$(lst_name)
|
||||||
|
obj.getList().parse(values)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function set_value(control, value){
|
function set_value(control, value){
|
||||||
obj = $$(control)
|
obj = $$(control)
|
||||||
obj.blockEvent()
|
obj.blockEvent()
|
||||||
|
@ -610,3 +616,11 @@ function set_value(control, value){
|
||||||
obj.unblockEvent()
|
obj.unblockEvent()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function grid_parse(grid_name, values){
|
||||||
|
obj = $$(grid_name)
|
||||||
|
obj.clearAll()
|
||||||
|
obj.parse(values)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -830,6 +830,56 @@ var options_admin_complements = [
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
var controls_add_sucursal = [{cols: [
|
||||||
|
{maxWidth: 20},
|
||||||
|
{view: 'text', id: 'txt_sucursal_add_name', name: 'sucursal_add_name',
|
||||||
|
label: 'Nombre: ', labelPosition: 'top', required: true},
|
||||||
|
{view: 'richselect', id: 'lst_sucursal_add_invoice', name: 'sucursal_add_invoice',
|
||||||
|
label: 'Serie Facturas: ', labelPosition: 'top', required: true, options: []},
|
||||||
|
{view: 'text', id: 'txt_sucursal_add_ticket', name: 'sucursal_add_ticket',
|
||||||
|
required: true, label: 'Serie Tickets: ', labelPosition: 'top'},
|
||||||
|
{view: 'button', id: 'cmd_add_sucursal', label: 'Agregar',
|
||||||
|
autowidth: true, type: 'iconButton', icon: 'plus'},
|
||||||
|
{maxWidth: 20},
|
||||||
|
]}]
|
||||||
|
|
||||||
|
|
||||||
|
var grid_sucursales_cols = [
|
||||||
|
{id: 'id', header: 'ID', hidden: true},
|
||||||
|
{id: 'delete', header: '', width: 30, css: 'delete'},
|
||||||
|
{id: 'name', header: 'Nombre', fillspace: 1},
|
||||||
|
{id: 'serie_invoice', header: 'Serie Facturas', fillspace: 1},
|
||||||
|
{id: 'serie_tickets', header: 'Serie Tickets', fillspace: 1},]
|
||||||
|
|
||||||
|
|
||||||
|
var grid_sucursales = {
|
||||||
|
view: 'datatable',
|
||||||
|
id: 'grid_sucursales',
|
||||||
|
select: 'row',
|
||||||
|
adjust: true,
|
||||||
|
headermenu: true,
|
||||||
|
footer: true,
|
||||||
|
columns: grid_sucursales_cols,
|
||||||
|
on:{
|
||||||
|
'data->onStoreUpdated':function(){
|
||||||
|
this.data.each(function(obj, i){
|
||||||
|
obj.delete = '-'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var options_admin_sucursales = [
|
||||||
|
{maxHeight: 10},
|
||||||
|
{template: 'Agregar Sucursal', type: 'section'},
|
||||||
|
{view: 'form', id: 'form_add_sucursal', rows: controls_add_sucursal},
|
||||||
|
{template: 'Sucursales', type: 'section'},
|
||||||
|
{cols: [{maxWidth: 10}, grid_sucursales, {maxWidth: 10}]},
|
||||||
|
{maxHeight: 20},
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
var tab_options = {
|
var tab_options = {
|
||||||
view: 'tabview',
|
view: 'tabview',
|
||||||
id: 'tab_options',
|
id: 'tab_options',
|
||||||
|
@ -845,24 +895,14 @@ var tab_options = {
|
||||||
view: 'scrollview', body: {rows: options_admin_complements}}},
|
view: 'scrollview', body: {rows: options_admin_complements}}},
|
||||||
{header: 'Otros', body: {id: 'tab_admin_otros', view: 'scrollview',
|
{header: 'Otros', body: {id: 'tab_admin_otros', view: 'scrollview',
|
||||||
body: {rows: options_admin_otros}}},
|
body: {rows: options_admin_otros}}},
|
||||||
|
{header: 'Sucursales', body: {id: 'tab_admin_sucursales', view: 'scrollview',
|
||||||
|
body: {rows: options_admin_sucursales}}},
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var utilidades_archivos = [
|
var utilidades_archivos = [
|
||||||
{maxHeight: 15},
|
{maxHeight: 5},
|
||||||
{template: 'Cargar Base de Datos de Factura Libre', type: 'section'},
|
|
||||||
{view: 'form', id: 'form_upload_bdfl', rows: [
|
|
||||||
{cols: [{},
|
|
||||||
{view: 'uploader', id: 'up_bdfl', autosend: false, link: 'lst_bdfl',
|
|
||||||
value: 'Seleccionar base de datos', upload: '/files/bdfl'}, {}]},
|
|
||||||
{cols: [{},
|
|
||||||
{view: 'list', id: 'lst_bdfl', name: 'bdfl',
|
|
||||||
type: 'uploader', autoheight: true, borderless: true}, {}]},
|
|
||||||
{cols: [{}, {view: 'button', id: 'cmd_subir_bdfl',
|
|
||||||
label: 'Subir base de datos de Factura Libre'}, {}]},
|
|
||||||
]},
|
|
||||||
{maxHeight: 15},
|
|
||||||
{template: 'Importar archivo CFDI (XML)', type: 'section'},
|
{template: 'Importar archivo CFDI (XML)', type: 'section'},
|
||||||
{view: 'form', id: 'form_upload_cfdixml', rows: [
|
{view: 'form', id: 'form_upload_cfdixml', rows: [
|
||||||
{cols: [{},
|
{cols: [{},
|
||||||
|
|
Loading…
Reference in New Issue