Solo falta definir el mensaje y los 15 min extras
This commit is contained in:
@@ -26,7 +26,7 @@ const regresar = async (body) => {
|
||||
if (!res.Equipo.enUso)
|
||||
throw new Error('Aun no se ha entregado el equipo al usuario.');
|
||||
|
||||
if (res.horaFin > ahora) {
|
||||
if (res.horaFin < ahora) {
|
||||
await multar({
|
||||
idOperadorMulta: idOperadorRegreso,
|
||||
idPrestamo: res.idPrestamo,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
const moment = require('moment');
|
||||
const multar = require('../Multa/multar');
|
||||
const validar = require('../../helper/validar');
|
||||
const dbPath = '../../db/tablas';
|
||||
const Equipo = require(`${dbPath}/Equipo`);
|
||||
@@ -23,12 +24,21 @@ const regresarNumeroInventario = async (body) => {
|
||||
include: [{ model: Equipo, where: { numeroInventario } }],
|
||||
});
|
||||
})
|
||||
.then((res) => {
|
||||
.then(async (res) => {
|
||||
if (!res)
|
||||
throw new Error('No existe un prestamo activo con este equipo.');
|
||||
if (!res.Equipo.enUso)
|
||||
throw new Error('Aun no se ha entregado el equipo al usuario.');
|
||||
idPrestamo = res.idPrestamo;
|
||||
|
||||
if (res.horaFin < ahora) {
|
||||
await multar({
|
||||
idOperadorMulta: idOperadorRegreso,
|
||||
idPrestamo: res.idPrestamo,
|
||||
idInfraccion: 1,
|
||||
descripcion: 'Demora',
|
||||
});
|
||||
}
|
||||
return Equipo.update(
|
||||
{ enUso: false, apartado: false },
|
||||
{ where: { idEquipo: res.Equipo.idEquipo } }
|
||||
|
||||
Reference in New Issue
Block a user