mini cambios#
This commit is contained in:
@@ -43,53 +43,51 @@ const activos = async (body) => {
|
||||
let whereCarrito = [{ idModulo }];
|
||||
|
||||
if (idTipoCarrito) whereCarrito.push({ idTipoCarrito });
|
||||
return Modulo.findOne({ where: { idModulo } })
|
||||
.then((res) => {
|
||||
if (!res) throw new Error('No existe este modulo.');
|
||||
return Prestamo.findAndCountAll({
|
||||
where: { activo: true, idPrestamo: { [Op.like]: `%${idPrestamo}%` } },
|
||||
include: [
|
||||
{
|
||||
model: Equipo,
|
||||
where: { numeroInventario: { [Op.like]: `%${numeroInventario}%` } },
|
||||
include: [
|
||||
{
|
||||
model: Carrito,
|
||||
where: { [Op.and]: whereCarrito },
|
||||
include: [{ model: TipoCarrito }, { model: Modulo }],
|
||||
attributes: ['idCarrito', 'sobrenombre'],
|
||||
},
|
||||
{ model: Status },
|
||||
],
|
||||
attributes: [
|
||||
'idEquipo',
|
||||
'numeroSerie',
|
||||
'numeroInventario',
|
||||
'sobrenombre',
|
||||
],
|
||||
},
|
||||
{
|
||||
model: Usuario,
|
||||
where: { usuario: { [Op.like]: `%${usuario}%` } },
|
||||
include: [{ model: TipoUsuario }, { model: Carrera }],
|
||||
attributes: ['idUsuario', 'usuario', 'nombre'],
|
||||
},
|
||||
],
|
||||
attributes: [
|
||||
'idPrestamo',
|
||||
'activo',
|
||||
'horaMaxRecoger',
|
||||
'horaInicio',
|
||||
'horaFin',
|
||||
'horaEntrega',
|
||||
'createdAt',
|
||||
],
|
||||
limit: 25,
|
||||
offset: 25 * (pagina - 1),
|
||||
order: [['createdAt', 'DESC']],
|
||||
});
|
||||
})
|
||||
.then((res) => ({ count: res.count, activos: res.rows }));
|
||||
return Modulo.findOne({ where: { idModulo } }).then((res) => {
|
||||
if (!res) throw new Error('No existe este modulo.');
|
||||
return Prestamo.findAndCountAll({
|
||||
where: { activo: true, idPrestamo: { [Op.like]: `%${idPrestamo}%` } },
|
||||
include: [
|
||||
{
|
||||
model: Equipo,
|
||||
where: { numeroInventario: { [Op.like]: `%${numeroInventario}%` } },
|
||||
include: [
|
||||
{
|
||||
model: Carrito,
|
||||
where: { [Op.and]: whereCarrito },
|
||||
include: [{ model: TipoCarrito }, { model: Modulo }],
|
||||
attributes: ['idCarrito', 'sobrenombre'],
|
||||
},
|
||||
{ model: Status },
|
||||
],
|
||||
attributes: [
|
||||
'idEquipo',
|
||||
'numeroSerie',
|
||||
'numeroInventario',
|
||||
'sobrenombre',
|
||||
],
|
||||
},
|
||||
{
|
||||
model: Usuario,
|
||||
where: { usuario: { [Op.like]: `%${usuario}%` } },
|
||||
include: [{ model: TipoUsuario }, { model: Carrera }],
|
||||
attributes: ['idUsuario', 'usuario', 'nombre'],
|
||||
},
|
||||
],
|
||||
attributes: [
|
||||
'idPrestamo',
|
||||
'activo',
|
||||
'horaMaxRecoger',
|
||||
'horaInicio',
|
||||
'horaFin',
|
||||
'horaEntrega',
|
||||
'createdAt',
|
||||
],
|
||||
limit: 25,
|
||||
offset: 25 * (pagina - 1),
|
||||
order: [['createdAt', 'DESC']],
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = activos;
|
||||
|
||||
@@ -20,7 +20,6 @@ const cancelarOperador = async (body) => {
|
||||
include: [{ model: Equipo }],
|
||||
});
|
||||
})
|
||||
|
||||
.then((res) => {
|
||||
if (!res) throw new Error('Este prestamo no existe.');
|
||||
if (!res.activo)
|
||||
|
||||
@@ -100,7 +100,7 @@ const historial = async (body) => {
|
||||
limit: 25,
|
||||
offset: 25 * (pagina - 1),
|
||||
order: [['createdAt', 'DESC']],
|
||||
}).then((res) => ({ count: res.count, historial: res.rows }));
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = historial;
|
||||
|
||||
@@ -68,7 +68,7 @@ const historialEquipo = async (body) => {
|
||||
limit: 25,
|
||||
offset: 25 * (pagina - 1),
|
||||
order: [['createdAt', 'DESC']],
|
||||
}).then((res) => ({ count: res.count, historialEquipo: res.rows }));
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = historialEquipo;
|
||||
|
||||
@@ -77,7 +77,7 @@ const historialUsuario = async (body) => {
|
||||
'canceladoUsuario',
|
||||
'createdAt',
|
||||
],
|
||||
}).then((res) => ({ count: res.count, historialUsuario: res.rows }));
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = historialUsuario;
|
||||
|
||||
Reference in New Issue
Block a user