sin reportes
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
const validar = require('../../helper/validar');
|
||||
const dbPath = '../../db/tablas';
|
||||
const Infraccion = require(`${dbPath}/Infraccion`);
|
||||
const Multa = require(`${dbPath}/Multa`);
|
||||
const Operador = require(`${dbPath}/Operador`);
|
||||
const Prestamo = require(`${dbPath}/Prestamo`);
|
||||
const Usuario = require(`${dbPath}/Usuario`);
|
||||
|
||||
const historialMultasEquipo = async (body) => {
|
||||
const idEquipo = validar.validarId(body.idEquipo);
|
||||
const pagina = validar.validarNumero(body.pagina, true);
|
||||
|
||||
return Multa.findAndCountAll({
|
||||
include: [
|
||||
{
|
||||
model: Prestamo,
|
||||
where: { idEquipo },
|
||||
include: [
|
||||
{ model: Usuario },
|
||||
{ model: Operador, as: 'OperadorRegreso' },
|
||||
],
|
||||
},
|
||||
{ model: Infraccion },
|
||||
],
|
||||
limit: 25,
|
||||
offset: 25 * (pagina - 1),
|
||||
order: [['createdAt', 'DESC']],
|
||||
}).then((res) => {
|
||||
for (let i = 0; i < res.rows.length; i++) {
|
||||
delete res.rows[i].dataValues.idInfraccion;
|
||||
delete res.rows[i].dataValues.idPrestamo;
|
||||
delete res.rows[i].dataValues.Prestamo.dataValues.idOperadorEntrega;
|
||||
delete res.rows[i].dataValues.Prestamo.dataValues.idOperadorRegreso;
|
||||
delete res.rows[i].dataValues.Prestamo.dataValues.idUsuario;
|
||||
delete res.rows[i].dataValues.Prestamo.dataValues.idEquipo;
|
||||
delete res.rows[i].dataValues.Prestamo.dataValues.OperadorRegreso
|
||||
.dataValues.password;
|
||||
delete res.rows[i].dataValues.Prestamo.dataValues.OperadorRegreso
|
||||
.dataValues.idTipoUsuario;
|
||||
delete res.rows[i].dataValues.Prestamo.dataValues.Usuario.dataValues
|
||||
.password;
|
||||
delete res.rows[i].dataValues.Prestamo.dataValues.Usuario.dataValues
|
||||
.idTipoUsuario;
|
||||
delete res.rows[i].dataValues.Prestamo.dataValues.Usuario.dataValues
|
||||
.idCarrera;
|
||||
}
|
||||
return { count: res.count, historialMultasEquipo: res.rows };
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = historialMultasEquipo;
|
||||
+20
-4
@@ -1,10 +1,12 @@
|
||||
const validar = require('../../helper/validar');
|
||||
const dbPath = '../../db/tablas';
|
||||
const Multa = require(`${dbPath}/Multa`);
|
||||
const Infraccion = require(`${dbPath}/Infraccion`);
|
||||
const Equipo = require(`${dbPath}/Equipo`);
|
||||
const Multa = require(`${dbPath}/Multa`);
|
||||
const Operador = require(`${dbPath}/Operador`);
|
||||
const Prestamo = require(`${dbPath}/Prestamo`);
|
||||
|
||||
const historialMultas = async (body) => {
|
||||
const historialMultasUsuario = async (body) => {
|
||||
const idUsuario = validar.validarId(body.idUsuario);
|
||||
const pagina = validar.validarNumero(body.pagina, true);
|
||||
|
||||
@@ -13,6 +15,10 @@ const historialMultas = async (body) => {
|
||||
{
|
||||
model: Prestamo,
|
||||
where: { idUsuario },
|
||||
include: [
|
||||
{ model: Equipo },
|
||||
{ model: Operador, as: 'OperadorRegreso' },
|
||||
],
|
||||
},
|
||||
{ model: Infraccion },
|
||||
],
|
||||
@@ -27,9 +33,19 @@ const historialMultas = async (body) => {
|
||||
delete res.rows[i].dataValues.Prestamo.dataValues.idOperadorRegreso;
|
||||
delete res.rows[i].dataValues.Prestamo.dataValues.idUsuario;
|
||||
delete res.rows[i].dataValues.Prestamo.dataValues.idEquipo;
|
||||
delete res.rows[i].dataValues.Prestamo.dataValues.OperadorRegreso
|
||||
.dataValues.password;
|
||||
delete res.rows[i].dataValues.Prestamo.dataValues.OperadorRegreso
|
||||
.dataValues.idTipoUsuario;
|
||||
delete res.rows[i].dataValues.Prestamo.dataValues.Equipo.dataValues
|
||||
.idCarrito;
|
||||
delete res.rows[i].dataValues.Prestamo.dataValues.Equipo.dataValues
|
||||
.idStatus;
|
||||
delete res.rows[i].dataValues.Prestamo.dataValues.Equipo.dataValues
|
||||
.idPrograma;
|
||||
}
|
||||
return { count: res.count, historialMultas: res.rows };
|
||||
return { count: res.count, historialMultasUsuario: res.rows };
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = historialMultas;
|
||||
module.exports = historialMultasUsuario;
|
||||
@@ -43,9 +43,9 @@ const multar = async (body) => {
|
||||
.then((res) =>
|
||||
Multa.create({
|
||||
descripcion,
|
||||
fechaFin: fechaFin.format(),
|
||||
idInfraccion,
|
||||
idPrestamo,
|
||||
fechaFin: fechaFin.format(),
|
||||
})
|
||||
)
|
||||
.then((res) => ({ message: `Se multo correctamente al alumno.` }));
|
||||
|
||||
Reference in New Issue
Block a user