Mejora #292
This commit is contained in:
parent
d70c35b4de
commit
0465b684f0
|
@ -543,3 +543,20 @@ class AppCfdiPay(object):
|
|||
values = req.params
|
||||
req.context['result'] = self._db.cfdipay(values)
|
||||
resp.status = falcon.HTTP_200
|
||||
|
||||
|
||||
class AppSATBancos(object):
|
||||
|
||||
def __init__(self, db):
|
||||
self._db = db
|
||||
|
||||
# ~ def on_get(self, req, resp):
|
||||
# ~ values = req.params
|
||||
# ~ req.context['result'] = self._db.get_sat_bancos(values)
|
||||
# ~ resp.status = falcon.HTTP_200
|
||||
|
||||
def on_post(self, req, resp):
|
||||
values = req.params
|
||||
req.context['result'] = self._db.satbancos(values)
|
||||
resp.status = falcon.HTTP_200
|
||||
|
||||
|
|
|
@ -3618,3 +3618,32 @@ def respaldar_db(values, path_bk):
|
|||
args = 'pg_dump -U postgres -Fc {} > "{}"'.format(db, path)
|
||||
_call(args)
|
||||
return
|
||||
|
||||
|
||||
def validate_rfc(value):
|
||||
msg = ''
|
||||
if len(value) < 12:
|
||||
msg = 'Longitud inválida del RFC'
|
||||
return msg
|
||||
l = 4
|
||||
if len(value)==12:
|
||||
l = 3
|
||||
s = value[0:l]
|
||||
r = re.match('[A-ZÑ&]{%s}' % l, s)
|
||||
msg = 'Caracteres inválidos al {} del RFC'
|
||||
if not r:
|
||||
return msg.format('inicio')
|
||||
s = value[-3:]
|
||||
r = re.match('[A-Z0-9]{3}', s)
|
||||
if not r:
|
||||
return msg.format('final')
|
||||
s = value[l:l+6]
|
||||
r = re.match('[0-9]{6}', s)
|
||||
msg = 'Fecha inválida en el RFC'
|
||||
if not r:
|
||||
return msg
|
||||
try:
|
||||
datetime.datetime.strptime(s, '%y%m%d')
|
||||
return ''
|
||||
except:
|
||||
return msg
|
||||
|
|
|
@ -17,7 +17,7 @@ from controllers.main import (AppEmpresas,
|
|||
AppMain, AppValues, AppPartners, AppProducts, AppInvoices, AppFolios,
|
||||
AppDocumentos, AppFiles, AppPreInvoices, AppCuentasBanco,
|
||||
AppMovimientosBanco, AppTickets, AppStudents, AppEmployees, AppNomina,
|
||||
AppInvoicePay, AppCfdiPay
|
||||
AppInvoicePay, AppCfdiPay, AppSATBancos
|
||||
)
|
||||
|
||||
|
||||
|
@ -58,6 +58,7 @@ api.add_route('/employees', AppEmployees(db))
|
|||
api.add_route('/nomina', AppNomina(db))
|
||||
api.add_route('/invoicepay', AppInvoicePay(db))
|
||||
api.add_route('/cfdipay', AppCfdiPay(db))
|
||||
api.add_route('/satbancos', AppSATBancos(db))
|
||||
|
||||
|
||||
# ~ Activa si usas waitress y NO estas usando servidor web
|
||||
|
|
|
@ -441,3 +441,6 @@ class StorageEngine(object):
|
|||
|
||||
def bankmovement(self, values):
|
||||
return main.MovimientosBanco.post(values)
|
||||
|
||||
def satbancos(self, values):
|
||||
return main.SATBancos.post(values)
|
||||
|
|
|
@ -1517,6 +1517,25 @@ class SATBancos(BaseModel):
|
|||
def __str__(self):
|
||||
return 'Banco: {} ({})'.format(self.name, self.key)
|
||||
|
||||
def _updaterfc(self, args):
|
||||
id = int(args['id'])
|
||||
values = util.loads(args['values'])
|
||||
msg = util.validate_rfc(values['rfc'])
|
||||
if msg:
|
||||
return {'ok': False, 'msg': msg}
|
||||
|
||||
q = (SATBancos
|
||||
.update(**values)
|
||||
.where(SATBancos.id==id))
|
||||
result = bool(q.execute())
|
||||
msg = 'RFC actualizado correctamente'
|
||||
return {'ok': result, 'msg': msg}
|
||||
|
||||
@classmethod
|
||||
def post(cls, values):
|
||||
opt = values.pop('opt')
|
||||
return getattr(cls, '_{}'.format(opt))(cls, values)
|
||||
|
||||
@classmethod
|
||||
def get_(cls):
|
||||
rows = SATBancos.select().dicts()
|
||||
|
|
|
@ -112,6 +112,11 @@ var controllers = {
|
|||
$$('cmd_subir_cfdixml').attachEvent('onItemClick', cmd_subir_cfdixml_click)
|
||||
$$('up_bdfl').attachEvent('onUploadComplete', up_bdfl_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('onBeforeEditStop', grid_admin_bancos_before_edit_stop)
|
||||
//~ $$('grid_admin_bancos').attachEvent('onAfterEditStop', grid_admin_bancos_after_edit_stop)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2276,3 +2281,64 @@ function grid_emisor_cuentas_banco_on_check(row, column, state){
|
|||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
function admin_sat_bank_update_rfc(id, rfc){
|
||||
var data = {opt: 'updaterfc', id: id, values: {rfc: rfc}}
|
||||
webix.ajax().post('/satbancos', 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){
|
||||
msg_ok(values.msg)
|
||||
}else{
|
||||
msg_error(values.msg)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
function grid_admin_bancos_after_edit_start(id){
|
||||
var grid = $$('grid_admin_bancos')
|
||||
|
||||
if(id['column']=='rfc'){
|
||||
var row = grid.getItem(id)
|
||||
if(row['key']=='999'){
|
||||
grid.editCancel()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function grid_admin_bancos_before_edit_stop(state, editor){
|
||||
var grid = $$('grid_admin_bancos')
|
||||
var row = grid.getItem(editor.row)
|
||||
|
||||
if(editor.column == 'rfc' && row['key']!='999'){
|
||||
var rfc = state.value
|
||||
if (rfc.length != 12){
|
||||
msg_error('Longitud incorrecta del RFC')
|
||||
grid.blockEvent()
|
||||
state.value = state.old
|
||||
grid.editCancel()
|
||||
grid.unblockEvent()
|
||||
return true
|
||||
}
|
||||
if(!validar_rfc(rfc)){
|
||||
grid.blockEvent()
|
||||
state.value = state.old
|
||||
grid.editCancel()
|
||||
grid.unblockEvent()
|
||||
return true
|
||||
}
|
||||
grid.blockEvent()
|
||||
state.value = state.value.trim().toUpperCase()
|
||||
grid.editCancel()
|
||||
grid.unblockEvent()
|
||||
admin_sat_bank_update_rfc(row.id, state.value)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -804,7 +804,9 @@ var grid_admin_monedas_cols = [
|
|||
var grid_admin_bancos_cols = [
|
||||
{id: 'id', header: 'ID', hidden: true},
|
||||
{id: 'key', header: 'Clave', footer: {content: 'countRows', css: 'right'}},
|
||||
{id: 'name', header: 'Nombre', adjust: 'data', footer: 'Bancos'},
|
||||
{id: 'name', header: 'Nombre', footer: 'Bancos', fillspace: true},
|
||||
{id: 'razon_social', header: 'Razón Social', fillspace: true},
|
||||
{id: 'rfc', header: 'RFC', width: 125, editor: 'text'},
|
||||
{id: 'activo', header: 'Activo', template: '{common.checkbox()}',
|
||||
editor: 'checkbox'},
|
||||
]
|
||||
|
@ -851,7 +853,7 @@ var grid_admin_bancos = {
|
|||
id: 'grid_admin_bancos',
|
||||
select: 'cell',
|
||||
adjust: true,
|
||||
autowidth: true,
|
||||
editable: true,
|
||||
headermenu: true,
|
||||
footer: true,
|
||||
columns: grid_admin_bancos_cols,
|
||||
|
@ -1027,7 +1029,7 @@ var sat_bancos = [
|
|||
{maxHeight: 20},
|
||||
{cols: [{maxWidth: 15}, {view: 'label', label: msg_bancos}, {}]},
|
||||
{maxHeight: 20},
|
||||
{cols: [{maxWidth: 15}, grid_admin_bancos, {}]},
|
||||
{cols: [{maxWidth: 15}, grid_admin_bancos]},
|
||||
{maxHeight: 20},
|
||||
]
|
||||
|
||||
|
|
Loading…
Reference in New Issue