mini cambios#

This commit is contained in:
xXpuma99Xx
2022-01-24 15:58:34 -06:00
parent 9af90dc0cf
commit ffadb76178
15 changed files with 119 additions and 111 deletions
+45 -47
View File
@@ -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)
+1 -1
View File
@@ -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;