end point multa desde panel usuario
This commit is contained in:
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user