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 {
|
||||
|
||||
@@ -7,6 +7,7 @@ const Equipo = require(`${dbPath}/Equipo`);
|
||||
const Multa = require(`${dbPath}/Multa`);
|
||||
const Operador = require(`${dbPath}/Operador`);
|
||||
const Prestamo = require(`${dbPath}/Prestamo`);
|
||||
const Usuario = require(`${dbPath}/Usuario`);
|
||||
|
||||
const regresarNumeroInventario = async (body) => {
|
||||
const ahora = moment();
|
||||
@@ -22,6 +23,7 @@ const regresarNumeroInventario = async (body) => {
|
||||
'id operador regreso',
|
||||
true
|
||||
);
|
||||
const update = { idOperadorRegreso };
|
||||
let diferencia = null;
|
||||
let idPrestamo = null;
|
||||
|
||||
@@ -49,25 +51,31 @@ const regresarNumeroInventario = async (body) => {
|
||||
if (res.Equipo.idStatus === 1)
|
||||
throw new Error('Aun no se ha entregado el equipo al usuario.');
|
||||
idPrestamo = res.idPrestamo;
|
||||
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(),
|
||||
});
|
||||
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 } }
|
||||
);
|
||||
Prestamo.update(update, { where: { idPrestamo } });
|
||||
})
|
||||
.then(() => {
|
||||
io.getIO().emit('actualizar');
|
||||
|
||||
@@ -27,6 +27,7 @@ const regresoInmediato = async (body) => {
|
||||
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) =>
|
||||
|
||||
@@ -33,6 +33,7 @@ const regresoInmediatoNumeroInventario = async (body) => {
|
||||
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) =>
|
||||
|
||||
Reference in New Issue
Block a user