This commit is contained in:
Lemuel Marquez
2021-01-13 12:00:11 -06:00
parent ff6699ff20
commit 5de85194fe
8 changed files with 53 additions and 75 deletions
+9 -12
View File
@@ -7,6 +7,8 @@ const Programa = require('../../db/tablas/Programa');
const liberacion = async (body) => {
let idServicio = validar.validarId(body.idServicio);
let correo = {};
let update = { idStatus: 6 };
return Servicio.findOne({
where: { idServicio },
@@ -14,14 +16,14 @@ const liberacion = async (body) => {
})
.then(async (res) => {
if (!res) throw new Error('No existe este Servicio Social.');
if (res.Programa.acatlan && !body.vistoBuenoAcatlan)
throw new Error(
'El programa de este Servicio Solcial es Acatlán Contigo y no se envio la variable validando este servicio.'
);
// if (res.Programa.acatlan && !body.vistoBuenoAcatlan)
// throw new Error(
// 'El programa de este Servicio Social es Acatlán Contigo y no se envio la variable validando este servicio.'
// );
switch (res.idStatus) {
case 5:
let correo = correos.terminoValidado(res.Usuario.nombre);
correo = correos.terminoValidado(res.Usuario.nombre);
if (body.vistoBuenoAcatlan) update.vistoBuenoAcatlan = true;
return gmail(correo.subject, res.correo, correo.msj);
case 1:
case 2:
@@ -44,12 +46,7 @@ const liberacion = async (body) => {
throw new Error('Este Servicio Social esta cancelado.');
}
})
.then((res) => {
let update = { idStatus: 6 };
if (body.vistoBuenoAcatlan) update.vistoBuenoAcatlan = true;
return Servicio.update(update, { where: { idServicio } });
})
.then((res) => Servicio.update(update, { where: { idServicio } }))
.then((res) => {
return {
message:
@@ -9,6 +9,7 @@ const cancelar = async (body) => {
let idServicio = validar.validarId(body.idServicio);
let mensaje = validar.validarAlfanumerico(body.mensaje, 'El mensaje', 800);
let correoResponsable = {};
let correoAlumno = {};
let emailResponsable = '';
return Servicio.findOne({
@@ -20,14 +21,12 @@ const cancelar = async (body) => {
})
.then((res) => {
if (!res) throw new Error('No existe este Servicio Social.');
switch (res.idStatus) {
case 1:
let correoAlumno = correos.preRegistroRechazadoAlumno(
correoAlumno = correos.preRegistroRechazadoAlumno(
mensaje,
res.Usuario.nombre
);
correoResponsable = correos.preRegistroRechazadoResponsable(
mensaje,
res.Usuario.nombre
@@ -53,19 +52,15 @@ const cancelar = async (body) => {
throw new Error('Este Servicio Social fue cancelado.');
}
})
.then((res) => {
return gmail(
correoResponsable.subject,
emailResponsable,
correoResponsable.msj
);
})
.then((res) => {
return Servicio.update(
.then((res) =>
gmail(correoResponsable.subject, emailResponsable, correoResponsable.msj)
)
.then((res) =>
Servicio.update(
{ idStatus: 7, cartaAceptacion: '' },
{ where: { idServicio } }
);
})
)
)
.then((res) => {
return { message: 'Se rechazo correctamente la Carta de Aceptación.' };
});
+10 -14
View File
@@ -9,6 +9,7 @@ const cancelar = async (body) => {
let idServicio = validar.validarId(body.idServicio);
let mensaje = validar.validarAlfanumerico(body.mensaje, 'El mensaje', 800);
let correoResponsable = {};
let correoAlumno = {};
let emailResponsable = '';
return Servicio.findOne({
@@ -22,11 +23,10 @@ const cancelar = async (body) => {
if (!res) throw new Error('No existe este Servicio Social.');
switch (res.idStatus) {
case 5:
let correoAlumno = correos.terminoRechazadoAlumno(
correoAlumno = correos.terminoRechazadoAlumno(
mensaje,
res.Usuario.nombre
);
correoResponsable = correos.terminoRechazadoResponsable(
mensaje,
res.Usuario.nombre
@@ -53,19 +53,15 @@ const cancelar = async (body) => {
throw new Error('Este Servicio Social fue cancelado.');
}
})
.then((res) => {
return gmail(
correoResponsable.subject,
emailResponsable,
correoResponsable.msj
);
})
.then((res) => {
return Servicio.update(
{ idStatus: 9, informeGlobal: "" },
.then((res) =>
gmail(correoResponsable.subject, emailResponsable, correoResponsable.msj)
)
.then((res) =>
Servicio.update(
{ idStatus: 9, informeGlobal: '' },
{ where: { idServicio } }
);
})
)
)
.then((res) => {
return { message: 'Se rechazo correctamente el Informe Global.' };
});
+10 -14
View File
@@ -9,6 +9,7 @@ const cancelar = async (body) => {
let idServicio = validar.validarId(body.idServicio);
let mensaje = validar.validarAlfanumerico(body.mensaje, 'El mensaje', 800);
let correoResponsable = {};
let correoAlumno = {};
let emailResponsable = '';
return Servicio.findOne({
@@ -22,11 +23,10 @@ const cancelar = async (body) => {
if (!res) throw new Error('No existe este Servicio Social.');
switch (res.idStatus) {
case 5:
let correoAlumno = correos.terminoRechazadoAlumno(
correoAlumno = correos.terminoRechazadoAlumno(
mensaje,
res.Usuario.nombre
);
correoResponsable = correos.terminoRechazadoResponsable(
mensaje,
res.Usuario.nombre
@@ -53,19 +53,15 @@ const cancelar = async (body) => {
throw new Error('Este Servicio Social fue cancelado.');
}
})
.then((res) => {
return gmail(
correoResponsable.subject,
emailResponsable,
correoResponsable.msj
);
})
.then((res) => {
return Servicio.update(
{ idStatus: 8, cartaTermino: "" },
.then((res) =>
gmail(correoResponsable.subject, emailResponsable, correoResponsable.msj)
)
.then((res) =>
Servicio.update(
{ idStatus: 8, cartaTermino: '' },
{ where: { idServicio } }
);
})
)
)
.then((res) => {
return { message: 'Se rechazo correctamente la Carta de Termino.' };
});
+1 -3
View File
@@ -48,9 +48,7 @@ const registro = async (body) => {
{ where: { idUsuario } }
);
})
.then((res) => {
return Servicio.update({ idStatus: 2 }, { where: { idServicio } });
})
.then((res) => Servicio.update({ idStatus: 2 }, { where: { idServicio } }))
.then((res) => {
return {
message:
+9 -14
View File
@@ -15,6 +15,7 @@ const registroValidado = async (body) => {
200
);
let correoResponsable = {};
let correoAlumno = {};
let emailResponsable = '';
return Servicio.findOne({
@@ -26,11 +27,9 @@ const registroValidado = async (body) => {
})
.then((res) => {
if (!res) throw new Error('No existe este Servicio Social.');
switch (res.idStatus) {
case 2:
let correoAlumno = correos.registroValidadoAlumno(res.Usuario.nombre);
correoAlumno = correos.registroValidadoAlumno(res.Usuario.nombre);
correoResponsable = correos.registroValidadoResponsable(
res.Usuario.nombre
);
@@ -63,20 +62,16 @@ const registroValidado = async (body) => {
);
}
})
.then((res) => {
return gmail(
correoResponsable.subject,
emailResponsable,
correoResponsable.msj
);
})
.then((res) => {
return Servicio.update(
.then((res) =>
gmail(correoResponsable.subject, emailResponsable, correoResponsable.msj)
)
.then((res) =>
Servicio.update(
// { idStatus: 3, direccion, telefono, fechaNacimiento },
{ idStatus: 4, direccion, telefono, fechaNacimiento },
{ where: { idServicio } }
);
})
)
)
.then((res) => {
return {
message:
+3 -2
View File
@@ -16,6 +16,7 @@ const serviciosAdmin = async (body) => {
? validar.validarNumeroCuenta(body.numeroCuenta)
: '';
let where = {};
let data = [];
if (idStatus) where.idStatus = idStatus;
return Servicio.findAll({
@@ -32,14 +33,14 @@ const serviciosAdmin = async (body) => {
{ model: Carrera },
{ model: Status },
],
order: [['updatedAt', 'DESC']],
}).then((res) => {
let data = [];
for (let i = pagina * 25 - 25; i < res.length && i < pagina * 25; i++)
data.push({
idServicio: res[i].idServicio,
fechaInicio: res[i].fechaInicio,
fechaFin: res[i].fechaFin,
createdAt: res[i].createdAt,
Usuario: {
idUsuario: res[i].Usuario.idUsuario,
usuario: res[i].Usuario.usuario,
@@ -18,6 +18,7 @@ const serviciosResponsable = async (body) => {
? validar.validarNumeroCuenta(body.numeroCuenta)
: '';
let where = { [Op.and]: [{ idStatus: { [Op.ne]: 10 } }] };
let data = [];
if (idStatus) where[Op.and].push({ idStatus });
return Usuario.findOne({ where: { idUsuario } })
@@ -40,11 +41,10 @@ const serviciosResponsable = async (body) => {
{ model: Carrera },
{ model: Status },
],
order: [['updatedAt', 'DESC']],
});
})
.then((res) => {
let data = [];
for (let i = pagina * 25 - 25; i < res.length && i < pagina * 25; i++)
data.push({
idServicio: res[i].idServicio,