solucion de errores e inscripciones
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
const validar = require('../../helper/validar');
|
||||
const dbPath = '../../db/tablas';
|
||||
const Usuario = require(`${dbPath}/Usuario`);
|
||||
const Inscripcion = require(`${dbPath}/Inscripcion`);
|
||||
|
||||
const todasInscripciones = async (body) => {
|
||||
return Inscripcion.findAll({
|
||||
include: [
|
||||
{
|
||||
model: Usuario,
|
||||
attributes: ['numeroCuenta'],
|
||||
},
|
||||
],
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = todasInscripciones;
|
||||
@@ -6,9 +6,9 @@ const {
|
||||
const dbPath = '../../db/tablas';
|
||||
const Carrera = require(`${dbPath}/Carrera`);
|
||||
const Inscripcion = require(`${dbPath}/Inscripcion`);
|
||||
const ahora = moment();
|
||||
|
||||
const inscripcion = async (body) => {
|
||||
const ahora = moment();
|
||||
const idUsuario = validarNumeroEntero(body.idUsuario, 'id Usuario', true);
|
||||
const idArea = validarNumeroEntero(body.idArea, 'id Area', true);
|
||||
const folio = body.folio;
|
||||
@@ -19,7 +19,7 @@ const inscripcion = async (body) => {
|
||||
.then((res) => {
|
||||
if (res) throw new Error('Este folio ya esta registrado');
|
||||
return Inscripcion.findOne({
|
||||
where: { idArea },
|
||||
where: { idUsuario, idArea },
|
||||
}).then((res) => {
|
||||
if (res) throw new Error('Ya estas registrado en esta área');
|
||||
return Inscripcion.create({
|
||||
@@ -28,7 +28,7 @@ const inscripcion = async (body) => {
|
||||
folio: body.folio,
|
||||
monto: body.monto,
|
||||
idArea,
|
||||
fechaIncripcion: ahora.format(),
|
||||
fechaInscripcion: ahora.format(),
|
||||
fechaTicket: body.fechaTicket,
|
||||
idFechaInscripcion: body.idFechaInscripcion,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user