1 min recoger
This commit is contained in:
@@ -76,7 +76,8 @@ const pedir = async (body) => {
|
||||
})
|
||||
.then((res) =>
|
||||
Prestamo.create({
|
||||
horaInicio: ahora.add(10, 'm').format(),
|
||||
// horaInicio: ahora.add(10, 'm').format(),
|
||||
horaInicio: ahora.add(1, 'm').format(),
|
||||
horaFin: ahora.add(120, 'm').format(),
|
||||
idUsuario,
|
||||
idEquipo,
|
||||
|
||||
@@ -1,27 +1,43 @@
|
||||
const moment = require('moment');
|
||||
const { validarId } = require('../../helper/validar');
|
||||
const dbPath = '../../db/tablas';
|
||||
const Carrito = require(`${dbPath}/Carrito`);
|
||||
const Equipo = require(`${dbPath}/Equipo`);
|
||||
const Modulo = require(`${dbPath}/Modulo`);
|
||||
const Prestamo = require(`${dbPath}/Prestamo`);
|
||||
const Programa = require(`${dbPath}/Programa`);
|
||||
const TipoCarrito = require(`${dbPath}/TipoCarrito`);
|
||||
|
||||
const status = async (body) => {
|
||||
const ahora = moment();
|
||||
const idPrestamo = validarId(body.idPrestamo);
|
||||
let idEquipo;
|
||||
|
||||
return Prestamo.findOne({
|
||||
where: { idPrestamo },
|
||||
include: [{ model: Equipo }],
|
||||
include: [
|
||||
{
|
||||
model: Equipo,
|
||||
include: [
|
||||
{
|
||||
model: Carrito,
|
||||
include: [{ model: TipoCarrito }, { model: Modulo }],
|
||||
},
|
||||
{ model: Programa },
|
||||
],
|
||||
},
|
||||
],
|
||||
}).then(async (res) => {
|
||||
if (!res) throw new Error('No existe este prestamo.');
|
||||
idEquipo = res.Equipo.idEquipo;
|
||||
delete res.dataValues.idUsuario;
|
||||
delete res.dataValues.idEquipo;
|
||||
delete res.dataValues.idOperadorRegreso;
|
||||
delete res.dataValues.idOperadorEntrega;
|
||||
delete res.dataValues.Equipo.dataValues.idCarrito;
|
||||
delete res.dataValues.Equipo.dataValues.idStatus;
|
||||
delete res.dataValues.idOperadorRegreso;
|
||||
delete res.dataValues.idEquipo;
|
||||
delete res.dataValues.Equipo.dataValues.idPrograma;
|
||||
delete res.dataValues.Equipo.dataValues.idStatus;
|
||||
delete res.dataValues.Equipo.dataValues.idCarrito;
|
||||
delete res.dataValues.Equipo.Carrito.dataValues.idTipoCarrito;
|
||||
delete res.dataValues.Equipo.Carrito.dataValues.idModulo;
|
||||
delete res.dataValues.Equipo.Carrito.dataValues.activo;
|
||||
if (!res.activo) {
|
||||
if (!res.horaEntrega)
|
||||
return {
|
||||
@@ -45,7 +61,10 @@ const status = async (body) => {
|
||||
prestamo: res,
|
||||
};
|
||||
} else if (moment(res.horaInicio) < ahora) {
|
||||
await Equipo.update({ apartado: false }, { where: { idEquipo } });
|
||||
await Equipo.update(
|
||||
{ apartado: false },
|
||||
{ where: { idEquipo: res.Equipo.idEquipo } }
|
||||
);
|
||||
await Prestamo.update({ activo: false }, { where: { idPrestamo } });
|
||||
return {
|
||||
message:
|
||||
|
||||
Reference in New Issue
Block a user