42 lines
1.1 KiB
JavaScript
42 lines
1.1 KiB
JavaScript
const { validarNumeroEntero } = require('../../helper/validar');
|
|
const dbPath = '../../db/tablas';
|
|
const Multa = require(`${dbPath}/Multa`);
|
|
const Operador = require(`${dbPath}/Operador`);
|
|
const Prestamo = require(`${dbPath}/Prestamo`);
|
|
|
|
const historialMultasEquipo = async (body) => {
|
|
const pagina = validarNumeroEntero(body.pagina, 'página', false);
|
|
const idEquipo = validarNumeroEntero(body.idEquipo, 'id equipo', true);
|
|
|
|
return Multa.findAndCountAll({
|
|
include: [
|
|
{
|
|
model: Prestamo,
|
|
where: { idEquipo },
|
|
attributes: [
|
|
'idPrestamo',
|
|
'activo',
|
|
'horaMaxRecoger',
|
|
'horaInicio',
|
|
'horaFin',
|
|
'horaEntrega',
|
|
'canceladoUsuario',
|
|
'regresoInmediato',
|
|
'createdAt',
|
|
],
|
|
},
|
|
{
|
|
model: Operador,
|
|
as: 'OperadorMulta',
|
|
attributes: ['idOperador', 'operador'],
|
|
},
|
|
],
|
|
attributes: ['idMulta', 'descripcion', 'fechaFin', 'createdAt'],
|
|
limit: 25,
|
|
offset: 25 * (pagina - 1),
|
|
order: [['createdAt', 'DESC']],
|
|
});
|
|
};
|
|
|
|
module.exports = historialMultasEquipo;
|