liberacion
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
const validar = require('../../helper/validar');
|
||||
const gmail = require('../../helper/gmail');
|
||||
const correos = require('../../helper/correos');
|
||||
const Servicio = require('../../db/tablas/Servicio');
|
||||
const Usuario = require('../../db/tablas/Usuario');
|
||||
|
||||
const liberacion = async (body) => {
|
||||
let idServicio = validar.validarId(body.idServicio);
|
||||
|
||||
return Servicio.findOne({
|
||||
where: { idServicio },
|
||||
include: [{ model: Usuario }],
|
||||
})
|
||||
.then(async (res) => {
|
||||
if (!res) throw new Error('No existe este Servicio Social.');
|
||||
|
||||
switch (res.idStatus) {
|
||||
case 5:
|
||||
let correo = correos.terminoValidado(res.Usuario.nombre);
|
||||
|
||||
return gmail(correo.subject, res.correo, correo.msj);
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
throw new Error(
|
||||
'Este Servicio Social aun no puede pasar a Liberación.'
|
||||
);
|
||||
case 6:
|
||||
throw new Error(
|
||||
'Este Servicio Social ya se encuentra en Liberación.'
|
||||
);
|
||||
case 7:
|
||||
case 8:
|
||||
case 9:
|
||||
throw new Error(
|
||||
'Este Servicio Social se encuentra rechazado. No se puede aceptar hasta que se corriga lo necesario.'
|
||||
);
|
||||
case 10:
|
||||
throw new Error('Este Servicio Social esta cancelado.');
|
||||
}
|
||||
})
|
||||
.then((res) => {
|
||||
return Servicio.update({ idStatus: 6 }, { where: { idServicio } });
|
||||
})
|
||||
.then((res) => {
|
||||
return {
|
||||
message:
|
||||
'Se cambio de estatus correctamente y se envio un correo al alumno informandole de su liberación.',
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = liberacion;
|
||||
Reference in New Issue
Block a user