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;
|
||||
Reference in New Issue
Block a user