From f32ce95a554a0269a11d9d2b2fdc9f8ca61317b7 Mon Sep 17 00:00:00 2001 From: xXpuma99Xx <51341582+xXpuma99Xx@users.noreply.github.com> Date: Thu, 27 Jan 2022 13:12:38 -0600 Subject: [PATCH] entrega inmediata --- server/controller/Prestamo/cancelarOperador.js | 6 +----- server/controller/Prestamo/cancelarUsuario.js | 2 +- server/controller/Prestamo/entregar.js | 2 +- server/controller/Prestamo/pedir.js | 2 +- server/controller/Prestamo/regresar.js | 2 +- server/controller/Prestamo/regresarNumeroInventario.js | 2 +- server/controller/Prestamo/reporte.js | 2 +- server/controller/Prestamo/status.js | 2 +- server/controller/Status/get.js | 2 +- server/db/install.js | 1 + server/db/tablas/Prestamo.js | 5 +++++ 11 files changed, 15 insertions(+), 13 deletions(-) diff --git a/server/controller/Prestamo/cancelarOperador.js b/server/controller/Prestamo/cancelarOperador.js index fdcb28d..604e818 100644 --- a/server/controller/Prestamo/cancelarOperador.js +++ b/server/controller/Prestamo/cancelarOperador.js @@ -27,12 +27,8 @@ const cancelarOperador = async (body) => { throw new Error( 'Este prestamo ya no esta activo, ya no se puede cancelar.' ); - // if (res.Equipo.idStatus === 2) - // throw new Error( - // 'El equipo ya fue entregado al usuario, ya no se puede cancelar.' - // ); return Equipo.update( - { idStatus: 3 }, + { idStatus: 4 }, { where: { idEquipo: res.Equipo.idEquipo } } ); }) diff --git a/server/controller/Prestamo/cancelarUsuario.js b/server/controller/Prestamo/cancelarUsuario.js index 1d6ba39..2e1fb13 100644 --- a/server/controller/Prestamo/cancelarUsuario.js +++ b/server/controller/Prestamo/cancelarUsuario.js @@ -22,7 +22,7 @@ const cancelarUsuario = async (body) => { 'El equipo ya fue entregado al usuario, ya no se puede cancelar.' ); return Equipo.update( - { idStatus: 3 }, + { idStatus: 4 }, { where: { idEquipo: res.Equipo.idEquipo } } ); }) diff --git a/server/controller/Prestamo/entregar.js b/server/controller/Prestamo/entregar.js index cb01943..cc47de0 100644 --- a/server/controller/Prestamo/entregar.js +++ b/server/controller/Prestamo/entregar.js @@ -34,7 +34,7 @@ const entregar = async (body) => { else if (res.Equipo.idStatus === 2) throw new Error('Ya se entrego el equipo al usuario.'); else if (moment(res.horaMaxRecoger) < ahora) - await Equipo.update({ idStatus: 3 }, { where: { idEquipo } }) + await Equipo.update({ idStatus: 4 }, { where: { idEquipo } }) .then((res) => Prestamo.update({ activo: false }, { where: { idPrestamo } }) ) diff --git a/server/controller/Prestamo/pedir.js b/server/controller/Prestamo/pedir.js index 1e8ac8c..3d1ff6a 100644 --- a/server/controller/Prestamo/pedir.js +++ b/server/controller/Prestamo/pedir.js @@ -62,7 +62,7 @@ const pedir = async (body) => { ); return Equipo.findOne({ where: { - idStatus: 3, + idStatus: 4, idPrograma, }, include: [ diff --git a/server/controller/Prestamo/regresar.js b/server/controller/Prestamo/regresar.js index c28beb6..10acba3 100644 --- a/server/controller/Prestamo/regresar.js +++ b/server/controller/Prestamo/regresar.js @@ -43,7 +43,7 @@ const regresar = async (body) => { fechaFin: ahoraAux.add(parseInt(diferencia / 15) * 7, 'd').format(), }); return Equipo.update( - { idStatus: 3 }, + { idStatus: 4 }, { where: { idEquipo: res.Equipo.idEquipo } } ); }) diff --git a/server/controller/Prestamo/regresarNumeroInventario.js b/server/controller/Prestamo/regresarNumeroInventario.js index e8f07f8..c45d0fc 100644 --- a/server/controller/Prestamo/regresarNumeroInventario.js +++ b/server/controller/Prestamo/regresarNumeroInventario.js @@ -50,7 +50,7 @@ const regresarNumeroInventario = async (body) => { fechaFin: ahoraAux.add(parseInt(diferencia / 15) * 7, 'd').format(), }); return Equipo.update( - { idStatus: 3 }, + { idStatus: 4 }, { where: { idEquipo: res.Equipo.idEquipo } } ); }) diff --git a/server/controller/Prestamo/reporte.js b/server/controller/Prestamo/reporte.js index 5f71087..96e98c8 100644 --- a/server/controller/Prestamo/reporte.js +++ b/server/controller/Prestamo/reporte.js @@ -110,7 +110,7 @@ const reporte = async (body) => { programa: res[i].Equipo.Programa ? res[i].Equipo.Programa.programa : null, - carrito: res[i].Equipo.Carrito.carrito, + carrito: res[i].Equipo.Carrito.sobrenombre, modulo: res[i].Equipo.Carrito.Modulo.modulo, tipoCarrito: res[i].Equipo.Carrito.TipoCarrito.tipoCarrito, nombre: res[i].Usuario.nombre, diff --git a/server/controller/Prestamo/status.js b/server/controller/Prestamo/status.js index 2818df8..6d164b7 100644 --- a/server/controller/Prestamo/status.js +++ b/server/controller/Prestamo/status.js @@ -33,7 +33,7 @@ const status = async (body) => { } else message = 'El equipo ya fue entregado al usuario.'; } else if (moment(res.horaMaxRecoger) < ahora) { await Equipo.update( - { idStatus: 3 }, + { idStatus: 4 }, { where: { idEquipo: res.Equipo.idEquipo } } ).then((res) => Prestamo.update({ activo: false }, { where: { idPrestamo } }) diff --git a/server/controller/Status/get.js b/server/controller/Status/get.js index 29d3503..19f85b1 100644 --- a/server/controller/Status/get.js +++ b/server/controller/Status/get.js @@ -1,6 +1,6 @@ const { Op } = require('sequelize'); const Status = require('../../db/tablas/Status'); -const get = async () => Status.findAll({ where: { idStatus: { [Op.gt]: 2 } } }); +const get = async () => Status.findAll({ where: { idStatus: { [Op.gt]: 3 } } }); module.exports = get; diff --git a/server/db/install.js b/server/db/install.js index 86ec4b2..df1376d 100644 --- a/server/db/install.js +++ b/server/db/install.js @@ -146,6 +146,7 @@ const dataStatus = async () => { const data = [ 'Apartado', 'En uso', + 'Entrega inmediata', 'Activo', 'Cargando', 'Reparación', diff --git a/server/db/tablas/Prestamo.js b/server/db/tablas/Prestamo.js index 71b820b..f79bf48 100644 --- a/server/db/tablas/Prestamo.js +++ b/server/db/tablas/Prestamo.js @@ -43,6 +43,11 @@ Prestamo.init( allowNull: true, defaultValue: null, }, + regresoRapido: { + type: DataTypes.BOOLEAN, + allowNull: false, + defaultValue: true, + }, }, { sequelize,