Files
pcpuma_acatlan_api/server/controller/Multa/historialMultasEquipo.js
T

52 lines
1.1 KiB
JavaScript
Raw Normal View History

2021-09-02 14:55:56 -05:00
const validar = require('../../helper/validar');
const dbPath = '../../db/tablas';
2021-09-14 18:17:17 -05:00
const Multa = require(`${dbPath}/Multa`);
const Operador = require(`${dbPath}/Operador`);
2021-09-02 14:55:56 -05:00
const Prestamo = require(`${dbPath}/Prestamo`);
2021-09-14 18:17:17 -05:00
const historialMultasEquipo = async (body) => {
2022-01-03 16:47:25 -06:00
const idEquipo = validar.validarNumeroEntero(
body.idEquipo,
'id equipo',
true
);
2022-01-03 17:05:29 -06:00
const pagina = validar.validarNumero(
body.pagina,
'página',
false,
null,
true,
true
);
2021-09-02 14:55:56 -05:00
return Multa.findAndCountAll({
include: [
{
model: Prestamo,
2021-09-14 18:17:17 -05:00
where: { idEquipo },
2022-01-20 22:01:14 -06:00
attributes: [
'idPrestamo',
'activo',
'horaMaxRecoger',
'horaInicio',
'horaFin',
'horaEntrega',
'canceladoUsuario',
'createdAt',
],
},
{
model: Operador,
as: 'OperadorMulta',
attributes: ['idOperador', 'operador'],
2021-09-02 14:55:56 -05:00
},
],
2022-01-20 22:01:14 -06:00
attributes: ['idMulta', 'descripcion', 'fechaFin', 'createdAt'],
2021-09-02 14:55:56 -05:00
limit: 25,
offset: 25 * (pagina - 1),
order: [['createdAt', 'DESC']],
2022-01-24 15:58:34 -06:00
});
2021-09-02 14:55:56 -05:00
};
2021-09-14 18:17:17 -05:00
module.exports = historialMultasEquipo;