diff --git a/server/controller/Prestamo/entregar.js b/server/controller/Prestamo/entregar.js index d0b4d71..0c85c41 100644 --- a/server/controller/Prestamo/entregar.js +++ b/server/controller/Prestamo/entregar.js @@ -18,6 +18,10 @@ const entregar = async (body) => { true ); let idEquipo; + let update = { + idOperadorEntrega, + horaInicio: ahora.format(), + }; return Operador.findOne({ where: { idOperador: idOperadorEntrega } }) .then((res) => { @@ -44,18 +48,12 @@ const entregar = async (body) => { 'Ya pasó el tiempo límite para recoger el equipo de cómputo.' ); }); + if (ahora > moment(`${ahora.format('YYYY-MM-DD')} 17:45`)) + update.horaFin = moment(`${ahora.format('YYYY-MM-DD')} 19:45`); + else update.horaInicio = ahora.add(2, 'h').format(); return Equipo.update({ idStatus: 2 }, { where: { idEquipo } }); }) - .then(() => { - Prestamo.update( - { - idOperadorEntrega, - horaInicio: ahora.format(), - horaFin: ahora.add(2, 'h').format(), - }, - { where: { idPrestamo } } - ); - }) + .then(() => Prestamo.update(update, { where: { idPrestamo } })) .then(() => Equipo.findOne({ where: { idEquipo }, diff --git a/server/controller/Prestamo/pedir.js b/server/controller/Prestamo/pedir.js index 1100092..cc634c5 100644 --- a/server/controller/Prestamo/pedir.js +++ b/server/controller/Prestamo/pedir.js @@ -13,7 +13,7 @@ const Usuario = require(`${dbPath}/Usuario`); const pedir = async (body) => { const ahora = moment(); - const horaMax = moment(`${ahora.format('YYYY-MM-DD')} 19:00`); + const horaMax = moment(`${ahora.format('YYYY-MM-DD')} 18:45`); const horaMin = moment(`${ahora.format('YYYY-MM-DD')} 09:00`); const idUsuario = validarNumeroEntero(body.idUsuario, 'id usuario', true); const idTipoCarrito = validarNumeroEntero(