pedir equipo busqueda de equipo organizar correctamente

This commit is contained in:
2022-03-24 12:51:17 -06:00
parent 2ec1584064
commit 8192645db6
2 changed files with 11 additions and 7 deletions
+7 -7
View File
@@ -2,7 +2,7 @@ const validar = require('../../helper/validar');
const dbPath = '../../db/tablas';
const Carrito = require(`${dbPath}/Carrito`);
const Equipo = require(`${dbPath}/Equipo`);
// const Motivo = require(`${dbPath}/Motivo`);
const Motivo = require(`${dbPath}/Motivo`);
const Programa = require(`${dbPath}/Programa`);
const Status = require(`${dbPath}/Status`);
@@ -21,17 +21,17 @@ const update = async (body) => {
const idPrograma = body.idPrograma
? validar.validarNumeroEntero(body.idPrograma, 'id programa', true)
: '';
// const motivo = body.motivo
// ? validar.validarAlfanumerico(body.motivo, 'motivo', true, 500)
// : '';
const motivo = body.motivo
? validar.validarAlfanumerico(body.motivo, 'motivo', true, 500)
: '';
let update = {};
return Status.findOne({ where: { idStatus } })
.then((res) => {
if (idStatus) {
if (!res) throw new Error('No existe este status.');
// if (!motivo)
// throw new Error('No se mando el motivo de cambio de status.');
if (!motivo)
throw new Error('No se mando el motivo de cambio de status.');
update.idStatus = idStatus;
}
@@ -55,7 +55,7 @@ const update = async (body) => {
})
.then(async (res) => {
if (!res) throw new Error('No existe este equipo.');
// if (idStatus) await Motivo.create({ motivo, idEquipo, idStatus });
if (idStatus) await Motivo.create({ motivo, idEquipo, idStatus });
return Equipo.update(update, { where: { idEquipo } });
})
.then(() => ({ message: 'Se actualizó correctamente el equipo.' }));
+4
View File
@@ -131,6 +131,10 @@ const pedir = async (body) => {
where: { idTipoCarrito, idModulo, activo: true },
},
],
order: [
['idCarrito', 'ASC'],
['equipo', 'ASC'],
],
});
})
.then((res) => {