correo
This commit is contained in:
@@ -17,6 +17,7 @@ const regresar = async (body) => {
|
||||
'id operador regreso',
|
||||
true
|
||||
);
|
||||
const update = { idOperadorRegreso };
|
||||
let diferencia = null;
|
||||
|
||||
return Operador.findOne({ where: { idOperador: idOperadorRegreso } })
|
||||
@@ -33,31 +34,30 @@ const regresar = async (body) => {
|
||||
throw new Error('Este préstamo ya no esta activo.');
|
||||
if (res.Equipo.idStatus === 1)
|
||||
throw new Error('Aun no se ha entregado el equipo al usuario.');
|
||||
diferencia = parseInt((ahora - moment(res.horaFin)) / 60000);
|
||||
if (diferencia >= 15)
|
||||
await Multa.create({
|
||||
idPrestamo,
|
||||
idInfraccion: 1,
|
||||
idOperadorMulta: idOperadorRegreso,
|
||||
descripcion: `Se paso por ${diferencia} minutos para entregar el equipo.`,
|
||||
fechaFin: ahoraAux.add(parseInt(diferencia / 15) * 7, 'd').format(),
|
||||
}).then((res) =>
|
||||
Usuario.update(
|
||||
{ multa: true },
|
||||
{ where: { idUsuario: res.idUsuario } }
|
||||
)
|
||||
);
|
||||
if (!res.regresoInmediato) {
|
||||
update.horaEntrega = ahora.format();
|
||||
update.activo = false;
|
||||
diferencia = parseInt((ahora - moment(res.horaFin)) / 60000);
|
||||
if (diferencia >= 15)
|
||||
await Multa.create({
|
||||
idPrestamo,
|
||||
idInfraccion: 1,
|
||||
idOperadorMulta: 1,
|
||||
descripcion: `Se paso por ${diferencia} minutos para entregar el equipo.`,
|
||||
fechaFin: ahoraAux.add(parseInt(diferencia / 15) * 7, 'd').format(),
|
||||
}).then((res) =>
|
||||
Usuario.update(
|
||||
{ multa: true },
|
||||
{ where: { idUsuario: res.idUsuario } }
|
||||
)
|
||||
);
|
||||
}
|
||||
return Equipo.update(
|
||||
{ idStatus: 4 },
|
||||
{ where: { idEquipo: res.idEquipo } }
|
||||
);
|
||||
})
|
||||
.then(() =>
|
||||
Prestamo.update(
|
||||
{ idOperadorRegreso, horaEntrega: ahora.format(), activo: false },
|
||||
{ where: { idPrestamo } }
|
||||
)
|
||||
)
|
||||
.then(() => Prestamo.update(update, { where: { idPrestamo } }))
|
||||
.then(() => {
|
||||
io.getIO().emit('actualizar');
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user