end point multa desde panel usuario

This commit is contained in:
xXpuma99Xx
2021-09-25 22:45:07 -05:00
parent de4007768a
commit 3a8f02d3ee
4 changed files with 16 additions and 4 deletions
+13 -1
View File
@@ -17,8 +17,9 @@ const multar = async (body) => {
'La descripción',
500
);
const fechaFin = moment();
let prestamo = {};
let fechaFin = moment();
return Operador.findOne({ where: { idOperador: idOperadorMulta } })
.then((res) => {
if (!res) throw new Error('No existe este operador.');
@@ -36,6 +37,17 @@ const multar = async (body) => {
.then((res) => {
if (!res) throw new Error('No existe este prestamo.');
prestamo = res;
return Usuario.findOne({ where: { idUsuario } });
})
.then((res) => {
if (!res) throw new Error('No existe este usuario.');
return Prestamo.findOne({ where: { idUsuario, activo: true } });
})
.then((res) => {
if (res)
throw new Error(
'No se puede multar a este usuario ya que tiene un prestamo activo.'
);
return Multa.findOne({ where: { idPrestamo } });
})
.then((res) => {