diff --git a/server/controller/Prestamo/activos.js b/server/controller/Prestamo/activos.js index 7dab9f4..6fc2542 100644 --- a/server/controller/Prestamo/activos.js +++ b/server/controller/Prestamo/activos.js @@ -1,4 +1,4 @@ -const { Op } = require('sequelize'); +const { Op, where } = require('sequelize'); const validar = require('../../helper/validar'); const dbPath = '../../db/tablas'; const Carrera = require(`${dbPath}/Carrera`); @@ -33,6 +33,12 @@ const activos = async (body) => { 20 ) : ''; + const carrito = body.carrito + ? validar.validarAlfanumerico(body.carrito, 'carrito', true) + : ''; + const equipo = body.equipo + ? validar.validarAlfanumerico(body.equipo, 'equipo', true) + : ''; let wherePrestamo = { [Op.or]: [ { activo: true }, @@ -42,7 +48,12 @@ const activos = async (body) => { ], }; let whereCarrito = [{ idModulo }]; + let whereEquipo = {}; + if (equipo) whereEquipo.equipo = equipo; + if (numeroInventario) + whereEquipo.numeroInventario = { [Op.like]: `%${numeroInventario}%` }; + if (carrito) whereCarrito.push({ carrito }); if (idTipoCarrito) whereCarrito.push({ idTipoCarrito }); if (idPrestamo) wherePrestamo.idPrestamo = { [Op.like]: `%${idPrestamo}%` }; return Modulo.findOne({ where: { idModulo } }).then((res) => { @@ -52,7 +63,7 @@ const activos = async (body) => { include: [ { model: Equipo, - where: { numeroInventario: { [Op.like]: `%${numeroInventario}%` } }, + where: whereEquipo, include: [ { model: Carrito, diff --git a/server/controller/Prestamo/regresar.js b/server/controller/Prestamo/regresar.js index 662ca91..2641367 100644 --- a/server/controller/Prestamo/regresar.js +++ b/server/controller/Prestamo/regresar.js @@ -45,7 +45,7 @@ const regresar = async (body) => { idOperadorMulta: 1, descripcion: `Se paso por ${diferencia} minutos para entregar el equipo.`, fechaFin: ahoraAux.add(parseInt(diferencia / 15) * 7, 'd').format(), - }).then((res) => + }).then(() => Usuario.update( { multa: true }, { where: { idUsuario: res.idUsuario } } diff --git a/server/controller/Prestamo/regresarNumeroInventario.js b/server/controller/Prestamo/regresarNumeroInventario.js index fd4932b..51c63e2 100644 --- a/server/controller/Prestamo/regresarNumeroInventario.js +++ b/server/controller/Prestamo/regresarNumeroInventario.js @@ -64,7 +64,7 @@ const regresarNumeroInventario = async (body) => { idOperadorMulta: 1, descripcion: `Se paso por ${diferencia} minutos para entregar el equipo.`, fechaFin: ahoraAux.add(parseInt(diferencia / 15) * 7, 'd').format(), - }).then((res) => + }).then(() => Usuario.update( { multa: true }, { where: { idUsuario: res.idUsuario } } diff --git a/server/controller/Prestamo/regresoInmediato.js b/server/controller/Prestamo/regresoInmediato.js index 9f30560..bcb78ca 100644 --- a/server/controller/Prestamo/regresoInmediato.js +++ b/server/controller/Prestamo/regresoInmediato.js @@ -30,7 +30,7 @@ const regresoInmediato = async (body) => { idOperadorMulta: 1, descripcion: `Se paso por ${diferencia} minutos para entregar el equipo.`, fechaFin: ahoraAux.add(parseInt(diferencia / 15) * 7, 'd').format(), - }).then((res) => + }).then(() => Usuario.update( { multa: true }, { where: { idUsuario: res.idUsuario } } diff --git a/server/controller/Prestamo/regresoInmediatoNumeroInventario.js b/server/controller/Prestamo/regresoInmediatoNumeroInventario.js index b721cc3..db5e6ee 100644 --- a/server/controller/Prestamo/regresoInmediatoNumeroInventario.js +++ b/server/controller/Prestamo/regresoInmediatoNumeroInventario.js @@ -40,7 +40,7 @@ const regresoInmediatoNumeroInventario = async (body) => { idOperadorMulta: 1, descripcion: `Se paso por ${diferencia} minutos para entregar el equipo.`, fechaFin: ahoraAux.add(parseInt(diferencia / 15) * 7, 'd').format(), - }).then((res) => + }).then(() => Usuario.update( { multa: true }, { where: { idUsuario: res.idUsuario } } diff --git a/server/controller/Prestamo/status.js b/server/controller/Prestamo/status.js index ab14a6b..8a7b8ac 100644 --- a/server/controller/Prestamo/status.js +++ b/server/controller/Prestamo/status.js @@ -37,7 +37,7 @@ const status = async (body) => { { where: { idEquipo: res.Equipo.idEquipo } } ).then(() => Prestamo.update( - { activo: false, canceladoOperador: true, idOperador: 1 }, + { activo: false, canceladoOperador: true, idOperadorRegreso: 1 }, { where: { idPrestamo } } ) ); diff --git a/server/controller/TipoCarrito/get.js b/server/controller/TipoCarrito/get.js index e0350c6..74cfce0 100644 --- a/server/controller/TipoCarrito/get.js +++ b/server/controller/TipoCarrito/get.js @@ -1,5 +1,5 @@ const TipoCarrito = require('../../db/tablas/TipoCarrito'); -const get = async () => TipoCarrito.findAll(); +const get = async () => TipoCarrito.findAll({ where: { idTipoCarrito: 1 } }); module.exports = get;