no idUsuario
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
const { Op } = require('sequelize');
|
||||
const { Op, where } = require('sequelize');
|
||||
const validar = require('../../helper/validar');
|
||||
const dbPath = '../../db/tablas';
|
||||
const Carrera = require(`${dbPath}/Carrera`);
|
||||
@@ -33,6 +33,12 @@ const activos = async (body) => {
|
||||
20
|
||||
)
|
||||
: '';
|
||||
const carrito = body.carrito
|
||||
? validar.validarAlfanumerico(body.carrito, 'carrito', true)
|
||||
: '';
|
||||
const equipo = body.equipo
|
||||
? validar.validarAlfanumerico(body.equipo, 'equipo', true)
|
||||
: '';
|
||||
let wherePrestamo = {
|
||||
[Op.or]: [
|
||||
{ activo: true },
|
||||
@@ -42,7 +48,12 @@ const activos = async (body) => {
|
||||
],
|
||||
};
|
||||
let whereCarrito = [{ idModulo }];
|
||||
let whereEquipo = {};
|
||||
|
||||
if (equipo) whereEquipo.equipo = equipo;
|
||||
if (numeroInventario)
|
||||
whereEquipo.numeroInventario = { [Op.like]: `%${numeroInventario}%` };
|
||||
if (carrito) whereCarrito.push({ carrito });
|
||||
if (idTipoCarrito) whereCarrito.push({ idTipoCarrito });
|
||||
if (idPrestamo) wherePrestamo.idPrestamo = { [Op.like]: `%${idPrestamo}%` };
|
||||
return Modulo.findOne({ where: { idModulo } }).then((res) => {
|
||||
@@ -52,7 +63,7 @@ const activos = async (body) => {
|
||||
include: [
|
||||
{
|
||||
model: Equipo,
|
||||
where: { numeroInventario: { [Op.like]: `%${numeroInventario}%` } },
|
||||
where: whereEquipo,
|
||||
include: [
|
||||
{
|
||||
model: Carrito,
|
||||
|
||||
@@ -45,7 +45,7 @@ const regresar = async (body) => {
|
||||
idOperadorMulta: 1,
|
||||
descripcion: `Se paso por ${diferencia} minutos para entregar el equipo.`,
|
||||
fechaFin: ahoraAux.add(parseInt(diferencia / 15) * 7, 'd').format(),
|
||||
}).then((res) =>
|
||||
}).then(() =>
|
||||
Usuario.update(
|
||||
{ multa: true },
|
||||
{ where: { idUsuario: res.idUsuario } }
|
||||
|
||||
@@ -64,7 +64,7 @@ const regresarNumeroInventario = async (body) => {
|
||||
idOperadorMulta: 1,
|
||||
descripcion: `Se paso por ${diferencia} minutos para entregar el equipo.`,
|
||||
fechaFin: ahoraAux.add(parseInt(diferencia / 15) * 7, 'd').format(),
|
||||
}).then((res) =>
|
||||
}).then(() =>
|
||||
Usuario.update(
|
||||
{ multa: true },
|
||||
{ where: { idUsuario: res.idUsuario } }
|
||||
|
||||
@@ -30,7 +30,7 @@ const regresoInmediato = async (body) => {
|
||||
idOperadorMulta: 1,
|
||||
descripcion: `Se paso por ${diferencia} minutos para entregar el equipo.`,
|
||||
fechaFin: ahoraAux.add(parseInt(diferencia / 15) * 7, 'd').format(),
|
||||
}).then((res) =>
|
||||
}).then(() =>
|
||||
Usuario.update(
|
||||
{ multa: true },
|
||||
{ where: { idUsuario: res.idUsuario } }
|
||||
|
||||
@@ -40,7 +40,7 @@ const regresoInmediatoNumeroInventario = async (body) => {
|
||||
idOperadorMulta: 1,
|
||||
descripcion: `Se paso por ${diferencia} minutos para entregar el equipo.`,
|
||||
fechaFin: ahoraAux.add(parseInt(diferencia / 15) * 7, 'd').format(),
|
||||
}).then((res) =>
|
||||
}).then(() =>
|
||||
Usuario.update(
|
||||
{ multa: true },
|
||||
{ where: { idUsuario: res.idUsuario } }
|
||||
|
||||
@@ -37,7 +37,7 @@ const status = async (body) => {
|
||||
{ where: { idEquipo: res.Equipo.idEquipo } }
|
||||
).then(() =>
|
||||
Prestamo.update(
|
||||
{ activo: false, canceladoOperador: true, idOperador: 1 },
|
||||
{ activo: false, canceladoOperador: true, idOperadorRegreso: 1 },
|
||||
{ where: { idPrestamo } }
|
||||
)
|
||||
);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const TipoCarrito = require('../../db/tablas/TipoCarrito');
|
||||
|
||||
const get = async () => TipoCarrito.findAll();
|
||||
const get = async () => TipoCarrito.findAll({ where: { idTipoCarrito: 1 } });
|
||||
|
||||
module.exports = get;
|
||||
|
||||
Reference in New Issue
Block a user