diff --git a/server/controller/Infraccion/get.js b/server/controller/Infraccion/get.js index 171f4f9..fa12ecc 100644 --- a/server/controller/Infraccion/get.js +++ b/server/controller/Infraccion/get.js @@ -1,5 +1,7 @@ const Infraccion = require('../../db/tablas/Infraccion'); +const { Op } = require('sequelize'); -const get = async () => Infraccion.findAll(); +const get = async () => + Infraccion.findAll({ where: { idInfraccion: { [Op.ne]: 1 } } }); module.exports = get; diff --git a/server/controller/Prestamo/regresar.js b/server/controller/Prestamo/regresar.js index 9190efd..aec630f 100644 --- a/server/controller/Prestamo/regresar.js +++ b/server/controller/Prestamo/regresar.js @@ -26,7 +26,7 @@ const regresar = async (body) => { if (!res.Equipo.enUso) throw new Error('Aun no se ha entregado el equipo al usuario.'); - if (res.horaFin > ahora) { + if (res.horaFin < ahora) { await multar({ idOperadorMulta: idOperadorRegreso, idPrestamo: res.idPrestamo, diff --git a/server/controller/Prestamo/regresarNumeroInventario.js b/server/controller/Prestamo/regresarNumeroInventario.js index ee290ff..ace5cd7 100644 --- a/server/controller/Prestamo/regresarNumeroInventario.js +++ b/server/controller/Prestamo/regresarNumeroInventario.js @@ -1,4 +1,5 @@ const moment = require('moment'); +const multar = require('../Multa/multar'); const validar = require('../../helper/validar'); const dbPath = '../../db/tablas'; const Equipo = require(`${dbPath}/Equipo`); @@ -23,12 +24,21 @@ const regresarNumeroInventario = async (body) => { include: [{ model: Equipo, where: { numeroInventario } }], }); }) - .then((res) => { + .then(async (res) => { if (!res) throw new Error('No existe un prestamo activo con este equipo.'); if (!res.Equipo.enUso) throw new Error('Aun no se ha entregado el equipo al usuario.'); idPrestamo = res.idPrestamo; + + if (res.horaFin < ahora) { + await multar({ + idOperadorMulta: idOperadorRegreso, + idPrestamo: res.idPrestamo, + idInfraccion: 1, + descripcion: 'Demora', + }); + } return Equipo.update( { enUso: false, apartado: false }, { where: { idEquipo: res.Equipo.idEquipo } } diff --git a/server/db/install.js b/server/db/install.js index f05244c..07ed86c 100644 --- a/server/db/install.js +++ b/server/db/install.js @@ -177,6 +177,7 @@ const dataAdmin = async () => { const dataInfraccion = async () => { const data = [ + { infraccion: 'Demora', gravedad: '1' }, { infraccion: 'Manchas de suciedad', gravedad: '1' }, { infraccion: 'Etiquetas Removidas', gravedad: '1' }, { infraccion: 'Rayon en carcasa', gravedad: '1' },