cambios en db y endpoints de get prestamo y pedir listos

This commit is contained in:
Lemuel Marquez
2021-04-29 02:23:26 -05:00
parent dc4093de31
commit e4c260f179
23 changed files with 40 additions and 906 deletions
+3 -6
View File
@@ -41,10 +41,7 @@ const pedir = async (body) => {
throw new Error(
'Este usuario tiene una multa activa, no puede solicitar un equipo de computo.'
);
return Prestamo.findOne({
where: { idUsuario },
include: [{ model: Equipo, where: { activo: true } }],
});
return Prestamo.findOne({ where: { idUsuario, activo: true } });
})
.then((res) => {
if (res)
@@ -53,7 +50,7 @@ const pedir = async (body) => {
);
return Equipo.findOne({
where: {
activo: false,
apartado: false,
idStatus: 1,
idPrograma: idPrograma ? idPrograma : null,
},
@@ -75,7 +72,7 @@ const pedir = async (body) => {
'No hay un equipo de computo con las características solicitadas disponible. Intenta más tarde o con otras características.'
);
idEquipo = res.idEquipo;
return Equipo.update({ activo: true }, { where: { idEquipo } });
return Equipo.update({ apartado: true }, { where: { idEquipo } });
})
.then((res) =>
Prestamo.create({