diff --git a/server/config/mariadb.conf.js b/server/config/mariadb.conf.js index 6b39e36..6ce2f1a 100644 --- a/server/config/mariadb.conf.js +++ b/server/config/mariadb.conf.js @@ -101,10 +101,66 @@ const agregarDetalleServicio = async (monto, numeroCuenta) => { }); }; +const borrarInscripcion = async (numeroCuenta) => { + const conn = await pool.getConnection().catch((err) => { + throw new Error('No se pudo conectar con la db. ' + err); + }); + + return conn + .query(`DELETE FROM alumno_inscrito WHERE id_cuenta = ${numeroCuenta}`) + .then((rows) => { + conn.end(); + return rows[0]; + }) + .catch((err) => { + conn.end(); + throw new Error('Hubo un problema con el querry.' + err); + }); +}; + +const borrarRecibo = async (folio) => { + const conn = await pool.getConnection().catch((err) => { + throw new Error('No se pudo conectar con la db. ' + err); + }); + + return conn + .query(`DELETE FROM recibo WHERE folio = ${folio}`) + .then((rows) => { + conn.end(); + return rows[0]; + }) + .catch((err) => { + conn.end(); + throw new Error('Hubo un problema con el querry.' + err); + }); +}; + +const borrarDetalleServicio = async (numeroCuenta) => { + const conn = await pool.getConnection().catch((err) => { + throw new Error('No se pudo conectar con la db. ' + err); + }); + + return conn + .query( + `DELETE FROM detalle_servicio WHERE id_Cuenta = ${numeroCuenta} AND id_servicio = 4` + ) + .then((rows) => { + conn.end(); + return rows[0]; + }) + .catch((err) => { + conn.end(); + throw new Error('Hubo un problema con el querry.' + err); + }); +}; + module.exports = { obtenerDatosUsr, obtenerCarrera, usuarioInscrito, agregarRecibo, agregarDetalleServicio, + borrarInscripcion, + borrarRecibo, + borrarDetalleServicio, }; diff --git a/server/routes/Admin.js b/server/routes/Admin.js index 84e2b68..c91ccd4 100644 --- a/server/routes/Admin.js +++ b/server/routes/Admin.js @@ -13,9 +13,6 @@ const motivo = require(`${controllerPath}/motivo`); const validarSinTicket = require(`${controllerPath}/validarSinTicket`); const validarTicket = require(`${controllerPath}/validarTicket`); const reporte = require(`${controllerPath}/reporte`); -const restarCredito = require(`${controllerPath}/restarCredito`); -const ticketsImpresion = require(`${controllerPath}/ticketsImpresion`); -const credito = require(`${controllerPath}/credito`); app.post(`${route}/login`, (req, res) => { return login(req.body) diff --git a/server/routes/Usuario.js b/server/routes/Usuario.js index 9ab9ea6..d953f7c 100644 --- a/server/routes/Usuario.js +++ b/server/routes/Usuario.js @@ -9,8 +9,6 @@ const controllerPath = '../controller/Usuario'; const login = require(`${controllerPath}/login`); const inscripciones = require(`${controllerPath}/inscripciones`); const inscripcionUsuario = require(`${controllerPath}/inscripcionUsuario`); -const agregarCredito = require(`${controllerPath}/agregarCredito`); -const credito = require(`${controllerPath}/credito`); app.post(`${route}/login`, (req, res) => { return login(req.body)