cancelacion de una inscripcion
This commit is contained in:
@@ -1,10 +1,16 @@
|
||||
const dbPath = '../../db/tablas';
|
||||
const Inscripcion = require(`${dbPath}/Inscripcion`);
|
||||
const Usuario = require(`${dbPath}/Usuario`);
|
||||
const { validarNumeroEntero } = require('../../helper/validar');
|
||||
|
||||
const cancelarInscripcion = async (body) => {
|
||||
const idInscripcion = validarNumeroEntero(
|
||||
body.idInscripcion,
|
||||
'id Inscripcion',
|
||||
true
|
||||
);
|
||||
|
||||
return Inscripcion.findOne({
|
||||
where: { idUsuario: body.idUsuario, folio: body.usuario },
|
||||
where: { idInscripcion },
|
||||
})
|
||||
.then((res) => {
|
||||
if (!res) throw new Error('Lo sentimos esta inscripción no existe.');
|
||||
@@ -14,8 +20,7 @@ const cancelarInscripcion = async (body) => {
|
||||
},
|
||||
{
|
||||
where: {
|
||||
idUsuario: body.idUsuario,
|
||||
folio: body.usuario,
|
||||
idInscripcion,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
@@ -19,7 +19,7 @@ const inscripcion = async (body, file) => {
|
||||
.then((res) => {
|
||||
if (res) throw new Error('Este folio ya esta registrado');
|
||||
return Inscripcion.findOne({
|
||||
where: { idUsuario, idArea },
|
||||
where: { idUsuario, idArea, cancelacion: 0 },
|
||||
}).then((res) => {
|
||||
if (res) throw new Error('Ya estas registrado en esta área');
|
||||
if (file && folio && body.fechaTicket) {
|
||||
|
||||
@@ -10,7 +10,7 @@ const inscripciones = async (body) => {
|
||||
}).then((res) => {
|
||||
if (!res) return [];
|
||||
return Inscripcion.findAll({
|
||||
where: { idUsuario: body.idUsuario },
|
||||
where: { idUsuario: body.idUsuario, cancelacion: 0 },
|
||||
attributes: [
|
||||
'idInscripcion',
|
||||
'validacion',
|
||||
|
||||
Reference in New Issue
Block a user