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

42 lines
1.1 KiB
JavaScript
Raw Normal View History

2022-02-01 06:44:34 -06:00
const { validarNumeroEntero } = require('../../helper/validar');
2021-09-02 14:55:56 -05:00
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-02-01 06:44:34 -06:00
const pagina = validarNumeroEntero(body.pagina, 'página', false);
const idEquipo = validarNumeroEntero(body.idEquipo, 'id equipo', 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',
2022-02-01 06:44:34 -06:00
'regresoInmediato',
2022-01-20 22:01:14 -06:00
'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;