2017-06-28 23:55:53 -05:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
import falcon
|
|
|
|
from middleware import get_template
|
|
|
|
|
|
|
|
|
2017-11-30 00:37:13 -06:00
|
|
|
class AppEmpresas(object):
|
|
|
|
template = 'empresas.html'
|
|
|
|
|
|
|
|
def __init__(self, db):
|
|
|
|
self._db = db
|
|
|
|
|
|
|
|
@falcon.after(get_template)
|
|
|
|
def on_get(self, req, resp):
|
2017-12-03 00:24:23 -06:00
|
|
|
values = req.params
|
2017-11-30 00:37:13 -06:00
|
|
|
resp.status = falcon.HTTP_200
|
|
|
|
|
|
|
|
def on_post(self, req, resp):
|
|
|
|
values = req.params
|
2018-06-03 00:00:04 -05:00
|
|
|
opt = values.pop('opt', '1')
|
|
|
|
if opt == '1':
|
|
|
|
req.context['result'] = self._db.empresa_agregar(values)
|
|
|
|
elif opt == '2':
|
|
|
|
req.context['result'] = self._db.respaldar_dbs()
|
2017-11-30 00:37:13 -06:00
|
|
|
resp.status = falcon.HTTP_200
|
|
|
|
|
2017-12-03 00:09:44 -06:00
|
|
|
def on_delete(self, req, resp):
|
|
|
|
values = req.params
|
|
|
|
if self._db.empresa_borrar(values):
|
|
|
|
resp.status = falcon.HTTP_200
|
|
|
|
else:
|
|
|
|
resp.status = falcon.HTTP_204
|
|
|
|
|
|
|
|
|
2017-06-28 23:55:53 -05:00
|
|
|
class AppLogin(object):
|
|
|
|
template = 'login.html'
|
|
|
|
|
|
|
|
def __init__(self, db):
|
|
|
|
self._db = db
|
|
|
|
|
|
|
|
@falcon.after(get_template)
|
|
|
|
def on_get(self, req, resp):
|
|
|
|
resp.status = falcon.HTTP_200
|
|
|
|
|
|
|
|
def on_post(self, req, resp):
|
|
|
|
session = req.env['beaker.session']
|
2018-01-09 15:13:40 -06:00
|
|
|
session.invalidate()
|
2017-06-28 23:55:53 -05:00
|
|
|
values = req.params
|
2017-10-12 12:40:05 -05:00
|
|
|
values['rfc'] = values['rfc'].upper()
|
2019-02-05 22:12:19 -06:00
|
|
|
values['ip'] = req.remote_addr
|
2017-11-22 00:46:23 -06:00
|
|
|
result, user = self._db.authenticate(values)
|
2017-06-28 23:55:53 -05:00
|
|
|
if result['login']:
|
|
|
|
session.save()
|
2017-11-22 00:46:23 -06:00
|
|
|
session['userobj'] = user
|
2017-06-28 23:55:53 -05:00
|
|
|
session['user'] = result['user']
|
2017-09-30 23:14:44 -05:00
|
|
|
session['rfc'] = values['rfc']
|
2017-09-21 23:24:18 -05:00
|
|
|
req.context['result'] = result
|
2017-06-28 23:55:53 -05:00
|
|
|
resp.status = falcon.HTTP_200
|
|
|
|
|
|
|
|
|
|
|
|
class AppLogout(object):
|
|
|
|
|
|
|
|
def __init__(self, db):
|
|
|
|
self._db = db
|
|
|
|
|
|
|
|
def on_get(self, req, resp):
|
|
|
|
session = req.env['beaker.session']
|
|
|
|
session.delete()
|
|
|
|
resp.status = falcon.HTTP_200
|
|
|
|
raise falcon.HTTPTemporaryRedirect('/')
|
|
|
|
|
|
|
|
|
2017-09-21 23:24:18 -05:00
|
|
|
class AppAdmin(object):
|
|
|
|
template = 'admin.html'
|
|
|
|
|
|
|
|
def __init__(self, db):
|
|
|
|
self._db = db
|
|
|
|
|
|
|
|
@falcon.after(get_template)
|
|
|
|
def on_get(self, req, resp):
|
|
|
|
resp.status = falcon.HTTP_200
|
|
|
|
|
|
|
|
|
2017-06-28 23:55:53 -05:00
|
|
|
class AppMain(object):
|
|
|
|
template = 'main.html'
|
|
|
|
|
|
|
|
def __init__(self, db):
|
|
|
|
self._db = db
|
|
|
|
|
|
|
|
@falcon.after(get_template)
|
|
|
|
def on_get(self, req, resp):
|
|
|
|
resp.status = falcon.HTTP_200
|
|
|
|
|
|
|
|
|
2017-10-02 00:12:22 -05:00
|
|
|
class AppValues(object):
|
2018-03-01 13:32:47 -06:00
|
|
|
TABLES = ('allusuarios', 'usuario', 'usuarioupdate', 'editusuario',
|
|
|
|
'addusuario')
|
2017-10-02 00:12:22 -05:00
|
|
|
|
|
|
|
def __init__(self, db):
|
|
|
|
self._db = db
|
|
|
|
|
2018-03-01 13:32:47 -06:00
|
|
|
def _valid_user(self, table, user):
|
2018-03-26 22:38:19 -06:00
|
|
|
if table in self.TABLES:
|
|
|
|
if user.es_admin or user.es_superusuario:
|
|
|
|
return True
|
|
|
|
else:
|
|
|
|
return False
|
2018-03-01 13:32:47 -06:00
|
|
|
|
|
|
|
return True
|
|
|
|
|
2017-10-02 00:12:22 -05:00
|
|
|
def on_get(self, req, resp, table):
|
|
|
|
values = req.params
|
2017-12-03 21:13:31 -06:00
|
|
|
session = req.env['beaker.session']
|
2018-06-25 22:56:02 -05:00
|
|
|
if req.path in ('/values/titlelogin', '/values/empresas'):
|
2018-01-25 23:06:03 -06:00
|
|
|
req.context['result'] = self._db.get_values(table, values, session)
|
|
|
|
resp.status = falcon.HTTP_200
|
|
|
|
return
|
|
|
|
|
2018-01-25 12:50:41 -06:00
|
|
|
if not 'userobj' in session and req.path != '/values/empresas':
|
2018-01-25 00:52:45 -06:00
|
|
|
session.invalidate()
|
|
|
|
raise falcon.HTTPTemporaryRedirect('/')
|
2018-01-24 23:10:58 -06:00
|
|
|
|
2017-11-22 00:46:23 -06:00
|
|
|
if table == 'admin':
|
2017-12-04 00:16:53 -06:00
|
|
|
req.context['result'] = session['userobj'].es_superusuario \
|
|
|
|
or session['userobj'].es_admin
|
2017-11-22 00:46:23 -06:00
|
|
|
else:
|
2018-03-01 13:32:47 -06:00
|
|
|
if not self._valid_user(table, session['userobj']):
|
|
|
|
resp.status = falcon.HTTP_403
|
|
|
|
return
|
|
|
|
|
2017-12-03 21:13:31 -06:00
|
|
|
req.context['result'] = self._db.get_values(table, values, session)
|
2017-10-02 00:12:22 -05:00
|
|
|
resp.status = falcon.HTTP_200
|
|
|
|
|
2017-11-15 00:12:55 -06:00
|
|
|
def on_delete(self, req, resp, table):
|
|
|
|
values = req.params
|
2017-12-03 21:13:31 -06:00
|
|
|
session = req.env['beaker.session']
|
2018-01-24 23:44:55 -06:00
|
|
|
|
2017-12-03 21:13:31 -06:00
|
|
|
if table == 'usuario' and (session['userobj'].id == int(values['id'])):
|
|
|
|
resp.status = falcon.HTTP_204
|
|
|
|
return
|
|
|
|
|
2018-03-01 13:32:47 -06:00
|
|
|
if not self._valid_user(table, session['userobj']):
|
|
|
|
resp.status = falcon.HTTP_403
|
|
|
|
return
|
|
|
|
|
2017-11-15 00:12:55 -06:00
|
|
|
if self._db.delete(table, values['id']):
|
|
|
|
resp.status = falcon.HTTP_200
|
|
|
|
else:
|
|
|
|
resp.status = falcon.HTTP_204
|
|
|
|
|
2017-10-08 22:01:19 -05:00
|
|
|
def on_post(self, req, resp, table):
|
|
|
|
file_object = req.get_param('upload')
|
|
|
|
if file_object is None:
|
|
|
|
session = req.env['beaker.session']
|
|
|
|
values = req.params
|
2018-03-01 13:32:47 -06:00
|
|
|
|
|
|
|
if not self._valid_user(table, session['userobj']):
|
|
|
|
resp.status = falcon.HTTP_403
|
|
|
|
return
|
|
|
|
|
2017-10-16 00:02:51 -05:00
|
|
|
if table == 'correo':
|
|
|
|
req.context['result'] = self._db.validate_email(values)
|
|
|
|
elif table == 'sendmail':
|
|
|
|
req.context['result'] = self._db.send_email(values, session)
|
2017-11-05 19:53:27 -06:00
|
|
|
elif table == 'enviarprefac':
|
|
|
|
req.context['result'] = self._db.enviar_prefac(values)
|
2017-12-19 01:22:22 -06:00
|
|
|
elif table == 'addmoneda':
|
|
|
|
req.context['result'] = self._db.add_moneda(values)
|
2017-11-14 20:04:01 -06:00
|
|
|
elif table == 'addunidad':
|
|
|
|
req.context['result'] = self._db.add_unidad(values)
|
2017-11-15 00:12:55 -06:00
|
|
|
elif table == 'addimpuesto':
|
|
|
|
req.context['result'] = self._db.add_impuesto(values)
|
2017-12-03 21:13:31 -06:00
|
|
|
elif table == 'addusuario':
|
|
|
|
req.context['result'] = self._db.add_usuario(values)
|
|
|
|
elif table == 'editusuario':
|
|
|
|
req.context['result'] = self._db.edit_usuario(values)
|
2017-11-29 23:57:31 -06:00
|
|
|
elif table == 'bdfl':
|
|
|
|
req.context['result'] = self._db.importar_bdfl()
|
2018-01-16 23:13:50 -06:00
|
|
|
elif table == 'invoicenotes':
|
|
|
|
req.context['result'] = self._db.save_invoice_notes(values)
|
2018-01-29 00:05:54 -06:00
|
|
|
elif table == 'nivedu':
|
|
|
|
req.context['result'] = self._db.add_nivel_educativo(values)
|
2017-10-16 00:02:51 -05:00
|
|
|
else:
|
|
|
|
req.context['result'] = self._db.validate_cert(values, session)
|
2017-10-08 22:01:19 -05:00
|
|
|
else:
|
|
|
|
req.context['result'] = self._db.add_cert(file_object)
|
|
|
|
resp.status = falcon.HTTP_200
|
|
|
|
|
|
|
|
|
2017-11-03 14:09:34 -06:00
|
|
|
class AppFiles(object):
|
|
|
|
|
|
|
|
def __init__(self, db):
|
|
|
|
self._db = db
|
|
|
|
|
|
|
|
def on_get(self, req, resp, table):
|
|
|
|
values = req.params
|
|
|
|
resp.status = falcon.HTTP_200
|
|
|
|
|
|
|
|
def on_post(self, req, resp, table):
|
|
|
|
session = req.env['beaker.session']
|
|
|
|
file_object = req.get_param('upload')
|
|
|
|
req.context['result'] = self._db.upload_file(session, table, file_object)
|
|
|
|
resp.status = falcon.HTTP_200
|
|
|
|
|
|
|
|
|
2017-10-16 00:02:51 -05:00
|
|
|
class AppConfig(object):
|
|
|
|
|
|
|
|
def __init__(self, db):
|
|
|
|
self._db = db
|
|
|
|
|
|
|
|
def on_get(self, req, resp):
|
|
|
|
values = req.params
|
|
|
|
req.context['result'] = self._db.get_config(values)
|
|
|
|
resp.status = falcon.HTTP_200
|
|
|
|
|
|
|
|
def on_post(self, req, resp):
|
|
|
|
values = req.params
|
|
|
|
req.context['result'] = self._db.add_config(values)
|
|
|
|
resp.status = falcon.HTTP_200
|
|
|
|
|
2018-01-01 17:55:04 -06:00
|
|
|
def on_delete(self, req, resp):
|
|
|
|
values = req.params
|
|
|
|
if self._db.delete('config', values['id']):
|
|
|
|
resp.status = falcon.HTTP_200
|
|
|
|
else:
|
|
|
|
resp.status = falcon.HTTP_204
|
2017-10-16 00:02:51 -05:00
|
|
|
|
2017-10-02 00:12:22 -05:00
|
|
|
|
2017-06-28 23:55:53 -05:00
|
|
|
class AppPartners(object):
|
|
|
|
|
|
|
|
def __init__(self, db):
|
|
|
|
self._db = db
|
|
|
|
|
|
|
|
def on_get(self, req, resp):
|
|
|
|
values = req.params
|
|
|
|
req.context['result'] = self._db.get_partners(values)
|
|
|
|
resp.status = falcon.HTTP_200
|
|
|
|
|
|
|
|
def on_post(self, req, resp):
|
|
|
|
values = req.params
|
2017-10-02 20:34:30 -05:00
|
|
|
req.context['result'] = self._db.partner(values)
|
2017-06-28 23:55:53 -05:00
|
|
|
resp.status = falcon.HTTP_200
|
|
|
|
|
|
|
|
def on_delete(self, req, resp):
|
|
|
|
values = req.params
|
2017-10-02 20:34:30 -05:00
|
|
|
if self._db.delete('partner', values['id']):
|
2017-06-28 23:55:53 -05:00
|
|
|
resp.status = falcon.HTTP_200
|
|
|
|
else:
|
|
|
|
resp.status = falcon.HTTP_204
|
2017-10-04 00:11:49 -05:00
|
|
|
|
|
|
|
|
2018-01-29 01:55:42 -06:00
|
|
|
class AppStudents(object):
|
|
|
|
|
|
|
|
def __init__(self, db):
|
|
|
|
self._db = db
|
|
|
|
|
|
|
|
def on_get(self, req, resp):
|
|
|
|
values = req.params
|
|
|
|
req.context['result'] = self._db.get_students(values)
|
|
|
|
resp.status = falcon.HTTP_200
|
|
|
|
|
|
|
|
def on_post(self, req, resp):
|
|
|
|
values = req.params
|
|
|
|
req.context['result'] = self._db.students(values)
|
|
|
|
resp.status = falcon.HTTP_200
|
|
|
|
|
|
|
|
def on_delete(self, req, resp):
|
|
|
|
values = req.params
|
|
|
|
if self._db.delete('students', values['id']):
|
|
|
|
resp.status = falcon.HTTP_200
|
|
|
|
else:
|
|
|
|
resp.status = falcon.HTTP_204
|
|
|
|
|
|
|
|
|
2017-10-04 00:11:49 -05:00
|
|
|
class AppProducts(object):
|
|
|
|
|
|
|
|
def __init__(self, db):
|
|
|
|
self._db = db
|
|
|
|
|
|
|
|
def on_get(self, req, resp):
|
|
|
|
values = req.params
|
|
|
|
req.context['result'] = self._db.get_products(values)
|
|
|
|
resp.status = falcon.HTTP_200
|
|
|
|
|
|
|
|
def on_post(self, req, resp):
|
|
|
|
values = req.params
|
2018-01-19 15:42:00 -06:00
|
|
|
req.context['result'] = self._db.products(values)
|
2017-10-04 00:11:49 -05:00
|
|
|
resp.status = falcon.HTTP_200
|
|
|
|
|
|
|
|
def on_delete(self, req, resp):
|
|
|
|
values = req.params
|
|
|
|
if self._db.delete('product', values['id']):
|
|
|
|
resp.status = falcon.HTTP_200
|
|
|
|
else:
|
|
|
|
resp.status = falcon.HTTP_204
|
2017-10-06 00:10:27 -05:00
|
|
|
|
|
|
|
|
|
|
|
class AppInvoices(object):
|
|
|
|
|
|
|
|
def __init__(self, db):
|
|
|
|
self._db = db
|
|
|
|
|
|
|
|
def on_get(self, req, resp):
|
|
|
|
values = req.params
|
2020-02-23 22:02:46 -06:00
|
|
|
session = req.env['beaker.session']
|
|
|
|
req.context['result'] = self._db.get_invoices(values, session['userobj'])
|
2017-10-06 00:10:27 -05:00
|
|
|
resp.status = falcon.HTTP_200
|
|
|
|
|
|
|
|
def on_post(self, req, resp):
|
|
|
|
values = req.params
|
2018-01-02 01:37:52 -06:00
|
|
|
session = req.env['beaker.session']
|
|
|
|
req.context['result'] = self._db.invoice(values, session['userobj'])
|
2017-10-06 00:10:27 -05:00
|
|
|
resp.status = falcon.HTTP_200
|
2020-01-07 00:32:48 -06:00
|
|
|
|
|
|
|
def on_put(self, req, resp):
|
|
|
|
values = req.params
|
|
|
|
session = req.env['beaker.session']
|
|
|
|
req.context['result'] = self._db.invoice_put(values, session['userobj'])
|
|
|
|
resp.status = falcon.HTTP_200
|
2017-10-06 00:10:27 -05:00
|
|
|
|
|
|
|
def on_delete(self, req, resp):
|
|
|
|
values = req.params
|
2018-06-25 22:56:02 -05:00
|
|
|
session = req.env['beaker.session']
|
|
|
|
if self._db.delete('invoice', values['id'], session['userobj']):
|
2017-10-06 00:10:27 -05:00
|
|
|
resp.status = falcon.HTTP_200
|
|
|
|
else:
|
|
|
|
resp.status = falcon.HTTP_204
|
2017-10-07 23:52:11 -05:00
|
|
|
|
|
|
|
|
2017-11-05 00:13:48 -06:00
|
|
|
class AppPreInvoices(object):
|
|
|
|
|
|
|
|
def __init__(self, db):
|
|
|
|
self._db = db
|
|
|
|
|
|
|
|
def on_get(self, req, resp):
|
|
|
|
values = req.params
|
|
|
|
req.context['result'] = self._db.get_preinvoices(values)
|
|
|
|
resp.status = falcon.HTTP_200
|
|
|
|
|
|
|
|
def on_post(self, req, resp):
|
|
|
|
values = req.params
|
|
|
|
req.context['result'] = self._db.preinvoice(values)
|
|
|
|
resp.status = falcon.HTTP_200
|
|
|
|
|
|
|
|
def on_delete(self, req, resp):
|
|
|
|
values = req.params
|
|
|
|
if self._db.delete('preinvoice', values['id']):
|
|
|
|
resp.status = falcon.HTTP_200
|
|
|
|
else:
|
|
|
|
resp.status = falcon.HTTP_204
|
|
|
|
|
|
|
|
|
2017-12-20 01:15:48 -06:00
|
|
|
class AppTickets(object):
|
|
|
|
|
|
|
|
def __init__(self, db):
|
|
|
|
self._db = db
|
|
|
|
|
|
|
|
def on_get(self, req, resp):
|
|
|
|
values = req.params
|
2020-02-23 22:02:46 -06:00
|
|
|
session = req.env['beaker.session']
|
|
|
|
req.context['result'] = self._db.get_tickets(values, session['userobj'])
|
2017-12-20 01:15:48 -06:00
|
|
|
resp.status = falcon.HTTP_200
|
|
|
|
|
|
|
|
def on_post(self, req, resp):
|
|
|
|
values = req.params
|
2018-01-02 01:37:52 -06:00
|
|
|
session = req.env['beaker.session']
|
|
|
|
req.context['result'] = self._db.tickets(values, session['userobj'])
|
2017-12-20 01:15:48 -06:00
|
|
|
resp.status = falcon.HTTP_200
|
|
|
|
|
|
|
|
|
2017-10-07 23:52:11 -05:00
|
|
|
class AppEmisor(object):
|
|
|
|
|
|
|
|
def __init__(self, db):
|
|
|
|
self._db = db
|
|
|
|
|
|
|
|
def on_get(self, req, resp):
|
|
|
|
values = req.params
|
|
|
|
session = req.env['beaker.session']
|
|
|
|
req.context['result'] = self._db.get_emisor(session['rfc'])
|
|
|
|
resp.status = falcon.HTTP_200
|
|
|
|
|
|
|
|
def on_post(self, req, resp):
|
|
|
|
values = req.params
|
|
|
|
req.context['result'] = self._db.emisor(values)
|
|
|
|
resp.status = falcon.HTTP_200
|
|
|
|
|
|
|
|
def on_delete(self, req, resp):
|
|
|
|
values = req.params
|
|
|
|
if self._db.delete('invoice', values['id']):
|
|
|
|
resp.status = falcon.HTTP_200
|
|
|
|
else:
|
|
|
|
resp.status = falcon.HTTP_204
|
2017-10-09 23:34:16 -05:00
|
|
|
|
|
|
|
|
2017-11-11 23:58:11 -06:00
|
|
|
class AppCuentasBanco(object):
|
|
|
|
|
|
|
|
def __init__(self, db):
|
|
|
|
self._db = db
|
|
|
|
|
|
|
|
def on_get(self, req, resp):
|
|
|
|
values = req.params
|
|
|
|
session = req.env['beaker.session']
|
2017-11-16 22:49:17 -06:00
|
|
|
req.context['result'] = self._db.get_cuentasbanco(values)
|
2017-11-11 23:58:11 -06:00
|
|
|
resp.status = falcon.HTTP_200
|
|
|
|
|
|
|
|
def on_post(self, req, resp):
|
|
|
|
values = req.params
|
|
|
|
req.context['result'] = self._db.cuentasbanco(values)
|
|
|
|
resp.status = falcon.HTTP_200
|
|
|
|
|
2017-11-17 14:13:39 -06:00
|
|
|
def on_delete(self, req, resp):
|
|
|
|
values = req.params
|
|
|
|
if self._db.delete('cuentasbanco', values['id']):
|
|
|
|
resp.status = falcon.HTTP_200
|
|
|
|
else:
|
|
|
|
resp.status = falcon.HTTP_204
|
|
|
|
|
2017-11-11 23:58:11 -06:00
|
|
|
|
2017-11-17 00:38:06 -06:00
|
|
|
class AppMovimientosBanco(object):
|
|
|
|
|
|
|
|
def __init__(self, db):
|
|
|
|
self._db = db
|
|
|
|
|
|
|
|
def on_get(self, req, resp):
|
|
|
|
values = req.params
|
|
|
|
session = req.env['beaker.session']
|
|
|
|
req.context['result'] = self._db.get_movimientosbanco(values)
|
|
|
|
resp.status = falcon.HTTP_200
|
|
|
|
|
|
|
|
def on_post(self, req, resp):
|
|
|
|
values = req.params
|
2018-09-10 00:00:52 -05:00
|
|
|
# ~ req.context['result'] = self._db.add_movbanco(values)
|
|
|
|
req.context['result'] = self._db.bankmovement(values)
|
2017-11-17 00:38:06 -06:00
|
|
|
resp.status = falcon.HTTP_200
|
|
|
|
|
2017-11-23 23:56:03 -06:00
|
|
|
def on_delete(self, req, resp):
|
|
|
|
values = req.params
|
|
|
|
if self._db.delete('movbanco', values['id']):
|
|
|
|
resp.status = falcon.HTTP_200
|
|
|
|
else:
|
|
|
|
resp.status = falcon.HTTP_204
|
|
|
|
|
2017-11-17 00:38:06 -06:00
|
|
|
|
2017-10-09 23:34:16 -05:00
|
|
|
class AppFolios(object):
|
|
|
|
|
|
|
|
def __init__(self, db):
|
|
|
|
self._db = db
|
|
|
|
|
|
|
|
def on_get(self, req, resp):
|
|
|
|
values = req.params
|
|
|
|
req.context['result'] = self._db.get_folios()
|
|
|
|
resp.status = falcon.HTTP_200
|
|
|
|
|
|
|
|
def on_post(self, req, resp):
|
|
|
|
values = req.params
|
|
|
|
req.context['result'] = self._db.add_folios(values)
|
|
|
|
resp.status = falcon.HTTP_200
|
|
|
|
|
|
|
|
def on_delete(self, req, resp):
|
|
|
|
values = req.params
|
|
|
|
if self._db.delete('folios', values['id']):
|
|
|
|
resp.status = falcon.HTTP_200
|
|
|
|
else:
|
|
|
|
resp.status = falcon.HTTP_204
|
2017-10-10 22:42:11 -05:00
|
|
|
|
|
|
|
|
2018-01-19 01:00:22 -06:00
|
|
|
class AppEmployees(object):
|
|
|
|
|
|
|
|
def __init__(self, db):
|
|
|
|
self._db = db
|
|
|
|
|
|
|
|
def on_get(self, req, resp):
|
|
|
|
values = req.params
|
|
|
|
req.context['result'] = self._db.get_employees(values)
|
|
|
|
resp.status = falcon.HTTP_200
|
|
|
|
|
|
|
|
def on_post(self, req, resp):
|
|
|
|
values = req.params
|
|
|
|
req.context['result'] = self._db.employees(values)
|
|
|
|
resp.status = falcon.HTTP_200
|
|
|
|
|
|
|
|
def on_delete(self, req, resp):
|
|
|
|
values = req.params
|
|
|
|
if self._db.delete('employee', values['id']):
|
|
|
|
resp.status = falcon.HTTP_200
|
|
|
|
else:
|
|
|
|
resp.status = falcon.HTTP_204
|
|
|
|
|
|
|
|
|
2018-01-26 01:52:59 -06:00
|
|
|
class AppNomina(object):
|
|
|
|
|
|
|
|
def __init__(self, db):
|
|
|
|
self._db = db
|
|
|
|
|
|
|
|
def on_get(self, req, resp):
|
|
|
|
values = req.params
|
2019-02-17 13:29:10 -06:00
|
|
|
by = values.get('by', '')
|
2018-01-26 01:52:59 -06:00
|
|
|
req.context['result'] = self._db.get_nomina(values)
|
2019-02-17 13:29:10 -06:00
|
|
|
if 'download' in by:
|
|
|
|
name = req.context['result']['name']
|
|
|
|
req.context['blob'] = req.context['result']['data']
|
|
|
|
resp.content_type = 'application/octet-stream'
|
|
|
|
resp.append_header(
|
|
|
|
'Content-Disposition', f'attachment; filename={name}')
|
2018-01-26 01:52:59 -06:00
|
|
|
resp.status = falcon.HTTP_200
|
|
|
|
|
|
|
|
def on_post(self, req, resp):
|
|
|
|
values = req.params
|
2019-04-01 23:09:32 -06:00
|
|
|
session = req.env['beaker.session']
|
|
|
|
req.context['result'] = self._db.nomina(values, session['userobj'])
|
2018-01-26 01:52:59 -06:00
|
|
|
resp.status = falcon.HTTP_200
|
|
|
|
|
|
|
|
def on_delete(self, req, resp):
|
|
|
|
values = req.params
|
2018-01-28 21:35:10 -06:00
|
|
|
if self._db.delete('nomina', values['id']):
|
2018-01-26 01:52:59 -06:00
|
|
|
resp.status = falcon.HTTP_200
|
|
|
|
else:
|
|
|
|
resp.status = falcon.HTTP_204
|
|
|
|
|
|
|
|
|
2017-10-10 22:42:11 -05:00
|
|
|
class AppDocumentos(object):
|
|
|
|
|
|
|
|
def __init__(self, db):
|
|
|
|
self._db = db
|
|
|
|
|
|
|
|
def on_get(self, req, resp, type_doc, id_doc):
|
2017-10-15 02:30:55 -05:00
|
|
|
session = req.env['beaker.session']
|
2017-10-10 22:42:11 -05:00
|
|
|
req.context['result'], file_name, content_type = \
|
2017-10-15 02:30:55 -05:00
|
|
|
self._db.get_doc(type_doc, id_doc, session['rfc'])
|
2018-11-19 01:03:48 -06:00
|
|
|
if not type_doc in ('pdf', 'pre', 'tpdf', 'pdfpago', 'html'):
|
2017-12-31 00:17:20 -06:00
|
|
|
resp.append_header('Content-Disposition',
|
|
|
|
'attachment; filename={}'.format(file_name))
|
2017-10-10 22:42:11 -05:00
|
|
|
resp.content_type = content_type
|
|
|
|
resp.status = falcon.HTTP_200
|
2018-08-24 00:52:59 -05:00
|
|
|
|
|
|
|
|
|
|
|
# ~ Revisado
|
|
|
|
class AppInvoicePay(object):
|
|
|
|
|
|
|
|
def __init__(self, db):
|
|
|
|
self._db = db
|
|
|
|
|
|
|
|
def on_get(self, req, resp):
|
|
|
|
values = req.params
|
|
|
|
req.context['result'] = self._db.get_invoicepay(values)
|
|
|
|
resp.status = falcon.HTTP_200
|
|
|
|
|
2018-08-24 23:04:10 -05:00
|
|
|
|
|
|
|
class AppCfdiPay(object):
|
|
|
|
|
|
|
|
def __init__(self, db):
|
|
|
|
self._db = db
|
|
|
|
|
|
|
|
def on_get(self, req, resp):
|
|
|
|
values = req.params
|
|
|
|
req.context['result'] = self._db.get_cfdipay(values)
|
|
|
|
resp.status = falcon.HTTP_200
|
|
|
|
|
|
|
|
def on_post(self, req, resp):
|
|
|
|
values = req.params
|
|
|
|
req.context['result'] = self._db.cfdipay(values)
|
|
|
|
resp.status = falcon.HTTP_200
|
2018-10-05 23:13:03 -05:00
|
|
|
|
|
|
|
|
|
|
|
class AppSATBancos(object):
|
|
|
|
|
|
|
|
def __init__(self, db):
|
|
|
|
self._db = db
|
|
|
|
|
2018-10-08 01:13:46 -05:00
|
|
|
def on_get(self, req, resp):
|
|
|
|
values = req.params
|
2018-10-10 22:25:10 -05:00
|
|
|
req.context['result'] = self._db.get_sat_bancos(values)
|
2018-10-08 01:13:46 -05:00
|
|
|
resp.status = falcon.HTTP_200
|
2018-10-05 23:13:03 -05:00
|
|
|
|
|
|
|
def on_post(self, req, resp):
|
|
|
|
values = req.params
|
2018-10-10 22:25:10 -05:00
|
|
|
req.context['result'] = self._db.sat_bancos(values)
|
|
|
|
resp.status = falcon.HTTP_200
|
|
|
|
|
|
|
|
|
|
|
|
class AppSATFormaPago(object):
|
|
|
|
|
|
|
|
def __init__(self, db):
|
|
|
|
self._db = db
|
|
|
|
|
|
|
|
def on_get(self, req, resp):
|
|
|
|
values = req.params
|
|
|
|
req.context['result'] = self._db.get_sat_forma_pago(values)
|
|
|
|
resp.status = falcon.HTTP_200
|
|
|
|
|
|
|
|
def on_post(self, req, resp):
|
|
|
|
values = req.params
|
|
|
|
req.context['result'] = self._db.sat_forma_pago(values)
|
2018-10-05 23:13:03 -05:00
|
|
|
resp.status = falcon.HTTP_200
|
|
|
|
|
2018-10-08 01:13:46 -05:00
|
|
|
|
2020-03-01 23:18:26 -06:00
|
|
|
class AppSATLeyendaFiscales(object):
|
|
|
|
|
|
|
|
def __init__(self, db):
|
|
|
|
self._db = db
|
|
|
|
|
|
|
|
def on_get(self, req, resp):
|
|
|
|
values = req.params
|
|
|
|
req.context['result'] = self._db.sat_leyendas_fiscales_get(values)
|
|
|
|
resp.status = falcon.HTTP_200
|
|
|
|
|
|
|
|
def on_post(self, req, resp):
|
|
|
|
values = req.params
|
|
|
|
req.context['result'] = self._db.sat_leyendas_fiscales_post(values)
|
|
|
|
resp.status = falcon.HTTP_200
|
|
|
|
|
|
|
|
def on_delete(self, req, resp):
|
|
|
|
values = req.params
|
|
|
|
if self._db.sat_leyendas_fiscales_delete(values['id']):
|
|
|
|
resp.status = falcon.HTTP_200
|
|
|
|
else:
|
|
|
|
resp.status = falcon.HTTP_204
|
|
|
|
|
|
|
|
|
2018-10-08 01:13:46 -05:00
|
|
|
class AppSociosCuentasBanco(object):
|
|
|
|
|
|
|
|
def __init__(self, db):
|
|
|
|
self._db = db
|
|
|
|
|
|
|
|
def on_get(self, req, resp):
|
|
|
|
values = req.params
|
|
|
|
req.context['result'] = self._db.get_partners_accounts_bank(values)
|
|
|
|
resp.status = falcon.HTTP_200
|
|
|
|
|
|
|
|
def on_post(self, req, resp):
|
|
|
|
values = req.params
|
|
|
|
req.context['result'] = self._db.partners_accounts_bank(values)
|
|
|
|
resp.status = falcon.HTTP_200
|
|
|
|
|
2020-12-30 22:45:57 -06:00
|
|
|
|
|
|
|
class AppCert(object):
|
|
|
|
|
|
|
|
def __init__(self, db):
|
|
|
|
self._db = db
|
|
|
|
|
|
|
|
def on_get(self, req, resp):
|
|
|
|
values = req.params
|
|
|
|
req.context['result'] = self._db.cert_get(values)
|
|
|
|
resp.status = falcon.HTTP_200
|
|
|
|
|
|
|
|
def on_post(self, req, resp):
|
|
|
|
values = req.params
|
|
|
|
req.context['result'] = self._db.cert_post(values)
|
|
|
|
resp.status = falcon.HTTP_200
|
|
|
|
|
2021-05-25 20:36:27 -05:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2021-06-13 23:12:07 -05:00
|
|
|
|
|
|
|
class AppPartnerProducts(object):
|
|
|
|
|
|
|
|
def __init__(self, db):
|
|
|
|
self._db = db
|
|
|
|
|
|
|
|
def on_get(self, req, resp):
|
|
|
|
values = req.params
|
|
|
|
req.context['result'] = self._db.partner_products_get(values)
|
|
|
|
resp.status = falcon.HTTP_200
|
|
|
|
|
|
|
|
def on_post(self, req, resp):
|
|
|
|
values = req.params
|
|
|
|
req.context['result'] = self._db.partner_products_post(values)
|
|
|
|
resp.status = falcon.HTTP_200
|
|
|
|
|
2021-06-15 23:45:11 -05:00
|
|
|
|
|
|
|
class AppInventoryEntries(object):
|
|
|
|
|
|
|
|
def __init__(self, db):
|
|
|
|
self._db = db
|
|
|
|
|
|
|
|
def on_get(self, req, resp):
|
|
|
|
values = req.params
|
|
|
|
req.context['result'] = self._db.inventory_entries_get(values)
|
|
|
|
resp.status = falcon.HTTP_200
|
|
|
|
|
|
|
|
def on_post(self, req, resp):
|
|
|
|
values = req.params
|
2021-07-08 12:56:40 -05:00
|
|
|
user = req.env['beaker.session']['userobj']
|
|
|
|
req.context['result'] = self._db.inventory_entries_post(values, user)
|
2021-06-15 23:45:11 -05:00
|
|
|
resp.status = falcon.HTTP_200
|
|
|
|
|
2021-07-21 22:04:13 -05:00
|
|
|
|
2021-07-23 22:01:59 -05:00
|
|
|
class AppWhareHouse(object):
|
|
|
|
|
|
|
|
def __init__(self, db):
|
|
|
|
self._db = db
|
|
|
|
|
|
|
|
def on_get(self, req, resp):
|
|
|
|
values = req.params
|
|
|
|
req.context['result'] = self._db.wharehouse_get(values)
|
|
|
|
resp.status = falcon.HTTP_200
|
|
|
|
|
|
|
|
def on_post(self, req, resp):
|
|
|
|
values = req.params
|
|
|
|
user = req.env['beaker.session']['userobj']
|
|
|
|
req.context['result'] = self._db.wharehouse_post(values, user)
|
|
|
|
resp.status = falcon.HTTP_200
|
|
|
|
|
|
|
|
|
2021-07-21 22:04:13 -05:00
|
|
|
class AppUsers(object):
|
|
|
|
|
|
|
|
def __init__(self, db):
|
|
|
|
self._db = db
|
|
|
|
|
|
|
|
def on_get(self, req, resp):
|
|
|
|
values = req.params
|
|
|
|
user = req.env['beaker.session']['userobj']
|
|
|
|
req.context['result'] = self._db.users_get(values, user)
|
|
|
|
resp.status = falcon.HTTP_200
|