opeardor multa y operador cancelacion
This commit is contained in:
@@ -15,12 +15,10 @@ const historialMultasEquipo = async (body) => {
|
||||
{
|
||||
model: Prestamo,
|
||||
where: { idEquipo },
|
||||
include: [
|
||||
{ model: Usuario },
|
||||
{ model: Operador, as: 'OperadorRegreso' },
|
||||
],
|
||||
include: [{ model: Usuario }],
|
||||
},
|
||||
{ model: Infraccion },
|
||||
{ model: Operador, as: 'OperadorMulta' },
|
||||
],
|
||||
limit: 25,
|
||||
offset: 25 * (pagina - 1),
|
||||
@@ -29,14 +27,15 @@ const historialMultasEquipo = async (body) => {
|
||||
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.idOperadorMulta;
|
||||
delete res.rows[i].dataValues.OperadorMulta.dataValues.password;
|
||||
delete res.rows[i].dataValues.OperadorMulta.dataValues.idTipoUsuario;
|
||||
delete res.rows[i].dataValues.OperadorMulta.dataValues.activo;
|
||||
delete res.rows[i].dataValues.Prestamo.dataValues.idOperadorEntrega;
|
||||
delete res.rows[i].dataValues.Prestamo.dataValues.idOperadorRegreso;
|
||||
delete res.rows[i].dataValues.Prestamo.dataValues.idOperadorCancelacion;
|
||||
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
|
||||
|
||||
@@ -28,10 +28,10 @@ const historialMultasUsuario = async (body) => {
|
||||
},
|
||||
],
|
||||
},
|
||||
{ model: Operador, as: 'OperadorRegreso' },
|
||||
],
|
||||
},
|
||||
{ model: Infraccion },
|
||||
{ model: Operador, as: 'OperadorMulta' },
|
||||
],
|
||||
limit: 25,
|
||||
offset: 25 * (pagina - 1),
|
||||
@@ -40,14 +40,15 @@ const historialMultasUsuario = async (body) => {
|
||||
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.idOperadorMulta;
|
||||
delete res.rows[i].dataValues.OperadorMulta.dataValues.password;
|
||||
delete res.rows[i].dataValues.OperadorMulta.dataValues.idTipoUsuario;
|
||||
delete res.rows[i].dataValues.OperadorMulta.dataValues.activo;
|
||||
delete res.rows[i].dataValues.Prestamo.dataValues.idOperadorEntrega;
|
||||
delete res.rows[i].dataValues.Prestamo.dataValues.idOperadorRegreso;
|
||||
delete res.rows[i].dataValues.Prestamo.dataValues.idOperadorCancelacion;
|
||||
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
|
||||
|
||||
@@ -2,11 +2,13 @@ const moment = require('moment');
|
||||
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 Multa = require(`${dbPath}/Multa`);
|
||||
|
||||
const multar = async (body) => {
|
||||
const idOperadorMulta = validar.validarId(body.idOperadorMulta);
|
||||
const idInfraccion = validar.validarId(body.idInfraccion);
|
||||
const idPrestamo = validar.validarId(body.idPrestamo);
|
||||
const descripcion = validar.validarAlfanumerico(
|
||||
@@ -17,7 +19,11 @@ const multar = async (body) => {
|
||||
let prestamo = {};
|
||||
let fechaFin = moment();
|
||||
|
||||
return Infraccion.findOne({ where: { idInfraccion } })
|
||||
return Operador.findOne({ where: { idOperador: idOperadorMulta } })
|
||||
.then((res) => {
|
||||
if (!res) throw new Error('No existe esta este operador.');
|
||||
return Infraccion.findOne({ where: { idInfraccion } });
|
||||
})
|
||||
.then((res) => {
|
||||
if (!res) throw new Error('No existe esta infracción.');
|
||||
if (res.gravedad == '1') fechaFin.add(7, 'd');
|
||||
@@ -44,6 +50,7 @@ const multar = async (body) => {
|
||||
Multa.create({
|
||||
descripcion,
|
||||
fechaFin: fechaFin.format(),
|
||||
idOperadorMulta,
|
||||
idInfraccion,
|
||||
idPrestamo,
|
||||
})
|
||||
|
||||
@@ -8,6 +8,7 @@ const Prestamo = require(`${dbPath}/Prestamo`);
|
||||
const Usuario = require(`${dbPath}/Usuario`);
|
||||
|
||||
const multar = async (body) => {
|
||||
const idOperadorMulta = validar.validarId(body.idOperadorMulta);
|
||||
const idInfraccion = validar.validarId(body.idInfraccion);
|
||||
const numeroInventario = validar.validarAlfanumerico(
|
||||
body.numeroInventario,
|
||||
@@ -22,7 +23,11 @@ const multar = async (body) => {
|
||||
let prestamo = {};
|
||||
let fechaFin = moment();
|
||||
|
||||
return Infraccion.findOne({ where: { idInfraccion } })
|
||||
return Operador.findOne({ where: { idOperador: idOperadorMulta } })
|
||||
.then((res) => {
|
||||
if (!res) throw new Error('No existe esta este operador.');
|
||||
return Infraccion.findOne({ where: { idInfraccion } });
|
||||
})
|
||||
.then((res) => {
|
||||
if (!res) throw new Error('No existe esta infracción.');
|
||||
if (res.gravedad == '1') fechaFin.add(7, 'd');
|
||||
@@ -52,6 +57,7 @@ const multar = async (body) => {
|
||||
.then((res) =>
|
||||
Multa.create({
|
||||
descripcion,
|
||||
idOperadorMulta,
|
||||
idInfraccion,
|
||||
idPrestamo: prestamo.idPrestamo,
|
||||
fechaFin: fechaFin.format(),
|
||||
|
||||
Reference in New Issue
Block a user