validaciones
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
const dbPath = '../../db/tablas';
|
||||
const { validarNumeroEntero } = require('../../helper/validar');
|
||||
const { Op } = require('sequelize');
|
||||
const Inscripcion = require(`${dbPath}/Inscripcion`);
|
||||
|
||||
const actualizarTicket = async (body) => {
|
||||
@@ -9,15 +10,32 @@ const actualizarTicket = async (body) => {
|
||||
true
|
||||
);
|
||||
|
||||
const monto = validarNumeroEntero(body.monto, 'monto', true);
|
||||
|
||||
return Inscripcion.findOne({
|
||||
where: { idInscripcion },
|
||||
where: {
|
||||
idInscripcion,
|
||||
},
|
||||
})
|
||||
.then((res) => {
|
||||
if (!res) throw new Error('No pudimos encontrar este ticket.');
|
||||
return Inscripcion.findOne({
|
||||
where: {
|
||||
folio: body.folio,
|
||||
cancelacion: 0,
|
||||
idInscripcion: {[Op.ne]: idInscripcion}
|
||||
},
|
||||
});
|
||||
})
|
||||
.then((res) => {
|
||||
if (res)
|
||||
throw new Error('¡ Este folio ya fue utilizado por otra inscripción !');
|
||||
})
|
||||
.then((res) => {
|
||||
return Inscripcion.update(
|
||||
{
|
||||
folio: body.folio,
|
||||
monto: body.monto,
|
||||
monto,
|
||||
fechaTicket: body.fechaTicket,
|
||||
},
|
||||
{
|
||||
@@ -32,7 +50,7 @@ const actualizarTicket = async (body) => {
|
||||
'¡ Los datos de la inscripción fueron actualizados de forma correcta !',
|
||||
}))
|
||||
.catch((err) => {
|
||||
throw new Error('No fue posible validar el ticket. ' + err);
|
||||
throw new Error('No fue posible actualizar los datos del ticket. ' + err);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
const dbPath = '../../db/tablas';
|
||||
const Inscripcion = require(`${dbPath}/Inscripcion`);
|
||||
const { validarNumeroEntero } = require('../../helper/validar');
|
||||
|
||||
const motivo = async (body) => {
|
||||
const folio = body.folio;
|
||||
return Inscripcion.findOne({
|
||||
where: { folio: body.folio },
|
||||
where: { folio },
|
||||
})
|
||||
.then((res) => {
|
||||
if (!res) throw new Error('No pudimos encontrar este ticket.');
|
||||
return Inscripcion.findOne({
|
||||
where: { folio: body.folio },
|
||||
where: { folio, validacion: 0 },
|
||||
attributes: ['motivo'],
|
||||
});
|
||||
})
|
||||
|
||||
@@ -29,29 +29,17 @@ const reporte = async (body) => {
|
||||
],
|
||||
})
|
||||
.then(async (res) => {
|
||||
if (body.tipo === 'CSV') {
|
||||
for (let i = 0; i < res.length; i++) {
|
||||
data.push({
|
||||
numero_cuenta: res[i].Usuario.numeroCuenta,
|
||||
id_area: res[i].idArea,
|
||||
folio: res[i].folio,
|
||||
monto: res[i].monto,
|
||||
hizo_pago: res[i].hizoPago,
|
||||
fecha_inscripcion: moment(res[i].fechaInscripcion).format('L'),
|
||||
});
|
||||
}
|
||||
} else {
|
||||
for (let i = 0; i < res.length; i++) {
|
||||
data.push({
|
||||
numeroCuenta: res[i].Usuario.numeroCuenta,
|
||||
validacion: res[i].validacion,
|
||||
folio: res[i].folio,
|
||||
monto: res[i].monto,
|
||||
hizoPago: res[i].hizoPago,
|
||||
fechaInscripcion: moment(res[i].fechaInscripcion).format('L'),
|
||||
idArea: res[i].idArea,
|
||||
});
|
||||
}
|
||||
for (let i = 0; i < res.length; i++) {
|
||||
data.push({
|
||||
numeroCuenta: res[i].Usuario.numeroCuenta,
|
||||
idArea: res[i].idArea,
|
||||
folio: res[i].folio,
|
||||
monto: res[i].monto,
|
||||
hizoPago: res[i].hizoPago,
|
||||
fechaInscripcion: moment(res[i].fechaInscripcion).format('L'),
|
||||
validacion: res[i].validacion,
|
||||
motivoCancelacion: res[i].motivo,
|
||||
});
|
||||
}
|
||||
await helper.eliminarArchivo(path).catch((err) => {});
|
||||
return helper.crearArchivo(path, convertArrayToCSV(data));
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
const validar = require('../../helper/validar');
|
||||
const {
|
||||
validarNumeroCuenta,
|
||||
validarNumeroEntero,
|
||||
} = require('../../helper/validar');
|
||||
const { Op } = require('sequelize');
|
||||
const dbPath = '../../db/tablas';
|
||||
const Usuario = require(`${dbPath}/Usuario`);
|
||||
const Inscripcion = require(`${dbPath}/Inscripcion`);
|
||||
|
||||
const todasInscripciones = async (body) => {
|
||||
// const numeroCuenta = validar.validarNumeroCuenta(body.numeroCuenta);
|
||||
const validacion = validarNumeroEntero(body.validacion, 'validacion', true);
|
||||
return Inscripcion.findAll({
|
||||
where: { validacion: body.validacion, cancelacion: 0 },
|
||||
where: { validacion, cancelacion: 0 },
|
||||
include: [
|
||||
{
|
||||
model: Usuario,
|
||||
|
||||
@@ -1,29 +1,16 @@
|
||||
const dbPath = '../../db/tablas';
|
||||
const Inscripcion = require(`${dbPath}/Inscripcion`);
|
||||
const Usuario = require(`${dbPath}/Usuario`);
|
||||
const { usuarioInscrito } = require('../../config/mariadb.conf');
|
||||
const { validarNumeroEntero } = require('../../helper/helper');
|
||||
|
||||
const validarSinTicket = async (body) => {
|
||||
// return usuarioInscrito(body.numeroCuenta, 0)
|
||||
// .then((res) => {
|
||||
// return Inscripcion.update(
|
||||
// {
|
||||
// validacion: 1,
|
||||
// },
|
||||
// {
|
||||
// where: {
|
||||
// idUsuario: body.idUsuario,
|
||||
// },
|
||||
// }
|
||||
// );
|
||||
// })
|
||||
const idUsuario = validarNumeroEntero(body.idUsuario, 'usuario', true);
|
||||
return Inscripcion.update(
|
||||
{
|
||||
validacion: 1,
|
||||
},
|
||||
{
|
||||
where: {
|
||||
idUsuario: body.idUsuario,
|
||||
idUsuario,
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
@@ -1,20 +1,24 @@
|
||||
const { obtenerDatosUsr } = require('../../config/mariadb.conf');
|
||||
const validar = require('../../helper/validar');
|
||||
const {
|
||||
validarNumeroCuenta,
|
||||
validarNumeroEntero,
|
||||
} = require('../../helper/validar');
|
||||
const dbPath = '../../db/tablas';
|
||||
const Carrera = require(`${dbPath}/Carrera`);
|
||||
const Usuario = require(`${dbPath}/Usuario`);
|
||||
|
||||
const escolares = async (body) => {
|
||||
// const numeroCuenta = validar.validarNumeroCuenta(body.numeroCuenta);
|
||||
|
||||
const numeroCuenta = validarNumeroCuenta(
|
||||
body.numeroCuenta,
|
||||
'numero cuenta',
|
||||
true
|
||||
);
|
||||
return Usuario.findOne({
|
||||
where: { numeroCuenta: body.numeroCuenta },
|
||||
where: { numeroCuenta },
|
||||
}).then((res) => {
|
||||
if (!res) {
|
||||
return obtenerDatosUsr(body.numeroCuenta).then(async (res) => {
|
||||
return obtenerDatosUsr(numeroCuenta).then(async (res) => {
|
||||
return Usuario.create({
|
||||
idUsuario: body.idUsuario,
|
||||
numeroCuenta: body.numeroCuenta,
|
||||
numeroCuenta,
|
||||
nombre: body.nombre,
|
||||
generacion: res.generacion,
|
||||
carrera: body.carrera,
|
||||
@@ -23,7 +27,7 @@ const escolares = async (body) => {
|
||||
});
|
||||
}
|
||||
return Usuario.findOne({
|
||||
where: { numeroCuenta: body.numeroCuenta },
|
||||
where: { numeroCuenta },
|
||||
attributes: [
|
||||
'idUsuario',
|
||||
'numeroCuenta',
|
||||
|
||||
@@ -18,7 +18,7 @@ const inscripcion = async (body, file) => {
|
||||
let email = '';
|
||||
|
||||
return Inscripcion.findOne({
|
||||
where: { folio },
|
||||
where: { folio, cancelacion: 0 },
|
||||
})
|
||||
.then((res) => {
|
||||
if (res) throw new Error('Este folio ya esta registrado');
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
const validar = require('../../helper/validar');
|
||||
const { validarNumeroEntero } = require('../../helper/validar');
|
||||
const dbPath = '../../db/tablas';
|
||||
const Inscripcion = require(`${dbPath}/Inscripcion`);
|
||||
|
||||
const inscripciones = async (body) => {
|
||||
// const numeroCuenta = validar.validarNumeroCuenta(body.numeroCuenta);
|
||||
const idUsuario = validarNumeroEntero(body.idUsuario, 'Usuario', true);
|
||||
|
||||
return Inscripcion.findAll({
|
||||
where: { idUsuario: body.idUsuario },
|
||||
where: { idUsuario },
|
||||
}).then((res) => {
|
||||
if (!res) return [];
|
||||
return Inscripcion.findAll({
|
||||
where: { idUsuario: body.idUsuario, cancelacion: 0 },
|
||||
where: { idUsuario, cancelacion: 0 },
|
||||
attributes: [
|
||||
'idInscripcion',
|
||||
'validacion',
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
const Usuario = require('./tablas/Usuario');
|
||||
const { encriptar } = require('../helper/encriptar');
|
||||
|
||||
const dataUsuarios = async () => {
|
||||
let usuario = ['416313221', '111111111', '222222222'];
|
||||
let nombre = [
|
||||
'Adriana De Luna Ramirez',
|
||||
'Nombre Falso 1',
|
||||
'Nombre Falso 2',
|
||||
];
|
||||
|
||||
for (let i = 0; i < usuario.length; i++) {
|
||||
await Usuario.create({
|
||||
usuario: usuario[i],
|
||||
nombre: nombre[i],
|
||||
password: encriptar('holi'),
|
||||
idTipoUsuario: 2,
|
||||
});
|
||||
console.log(`Se insertó el usuario ${usuario[i]}.`.magenta);
|
||||
}
|
||||
};
|
||||
|
||||
const exec = async () => {
|
||||
await dataUsuarios();
|
||||
console.log(
|
||||
'\nSe ha instalado exitosamente la información falsa en la base de datos.\n'
|
||||
.underline.bold.green
|
||||
);
|
||||
process.exit();
|
||||
};
|
||||
|
||||
exec();
|
||||
@@ -30,7 +30,6 @@ Inscripcion.init(
|
||||
type: DataTypes.STRING(10),
|
||||
allowNull: true,
|
||||
defaultValue: null,
|
||||
unique: true,
|
||||
},
|
||||
monto: {
|
||||
type: DataTypes.INTEGER,
|
||||
|
||||
@@ -8,7 +8,7 @@ const correoInscripciones = () => ({
|
||||
|
||||
<p>Te sugerimos guardar tu ticket para cualquier aclaración</p>
|
||||
|
||||
<p>Por el momento podras hacer tu confirmacion en <a href="https://kalinga.acatlan.unam.mx/cedetec/" target="_blanc">KALINGA</a></p>
|
||||
<p>Por el momento podras hacer tu confirmación en <a href="https://kalinga.acatlan.unam.mx/cedetec/" target="_blanc">KALINGA</a></p>
|
||||
|
||||
<p>En caso de recibir un correo con el asunto Inscripción declinada se cancelara el servicio y no podras hacer uso de los servicios</p>
|
||||
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
numeroCuenta,validacion,folio,monto,hizoPago,fechaInscripcion,idArea
|
||||
419085500,2,44,555,true,03/17/2022,1
|
||||
numeroCuenta,idArea,folio,monto,hizoPago,fechaInscripcion,validacion,motivoCancelacion
|
||||
419085500,1,9084161,11,true,03/18/2022,0,Se uso para impresiones
|
||||
|
||||
|
Reference in New Issue
Block a user