From a9d148e7144482bd96e1191b001acc7fdb5aa0f5 Mon Sep 17 00:00:00 2001 From: Andres2908 Date: Fri, 18 Mar 2022 00:29:38 -0600 Subject: [PATCH] motivo de declinacion --- server/controller/Admin/reporte.js | 1 - server/controller/Admin/validarTicket.js | 87 ++++++++++++------------ server/db/tablas/Inscripcion.js | 4 ++ server/helper/correo.js | 12 +++- server/uploads/reporte.csv | 4 +- 5 files changed, 57 insertions(+), 51 deletions(-) diff --git a/server/controller/Admin/reporte.js b/server/controller/Admin/reporte.js index afff08d..e0894da 100644 --- a/server/controller/Admin/reporte.js +++ b/server/controller/Admin/reporte.js @@ -45,7 +45,6 @@ const reporte = async (body) => { data.push({ numeroCuenta: res[i].Usuario.numeroCuenta, validacion: res[i].validacion, - confirmacion: res[i].confirmacion, folio: res[i].folio, monto: res[i].monto, hizoPago: res[i].hizoPago, diff --git a/server/controller/Admin/validarTicket.js b/server/controller/Admin/validarTicket.js index 1966692..2654421 100644 --- a/server/controller/Admin/validarTicket.js +++ b/server/controller/Admin/validarTicket.js @@ -1,60 +1,57 @@ const dbPath = '../../db/tablas'; const Inscripcion = require(`${dbPath}/Inscripcion`); -const Usuario = require(`${dbPath}/Usuario`); -const { usuarioInscrito } = require('../../config/mariadb.conf'); const validarTicket = async (body) => { - return ( - Inscripcion.findOne({ - where: { folio: body.folio }, + return Inscripcion.findOne({ + where: { folio: body.folio }, + }) + .then((res) => { + if (!res) throw new Error('Este folio no existe'); + idUsuario = res.idUsuario; + if (body.validacion == 1) { + return Inscripcion.findOne({ + where: { folio: body.folio, validacion: 1 }, + }); + } }) - .then((res) => { - if (!res) throw new Error('Este folio no existe'); - idUsuario = res.idUsuario; - if (body.validacion == 1) { - return Inscripcion.findOne({ - where: { folio: body.folio, validacion: 1 }, - }); - } - }) - .then((res) => { - if (res) throw new Error('Este folio ya fue validado'); - return Inscripcion.update( - { - validacion: body.validacion, + .then((res) => { + if (res) throw new Error('Este folio ya fue validado'); + return Inscripcion.update( + { + validacion: body.validacion, + }, + { + where: { + folio: body.folio, }, + } + ); + }) + .then((res) => { + if (body.validacion === 0) { + return Inscripcion.update( + { motivo: body.motivo }, { where: { folio: body.folio, }, } ); - }) - .then((res) => { - if (body.validacion === 0) - throw new Error( - 'El administrador a declinado el ticket, ya que los datos no coinciden.' - ); - }) - // .then((res) => { - // return Usuario.findOne({ - // where: { idUsuario }, - // attributes: ['numeroCuenta'], - // }).then((res) => { - // return usuarioInscrito(res.numeroCuenta, 1).then(async (res) => { - // return { - // message: '¡ El ticket a sido validado de forma correcta !', - // }; - // }); - // }); - // }) - .then((res) => ({ - message: '¡El ticket a sido validado de forma correcta!', - })) - .catch((err) => { - throw new Error('No fue posible validar el ticket. ' + err); - }) - ); + } + }) + .then((res) => { + if (body.validacion === 1) + return { + message: '¡El ticket a sido validado de forma correcta!', + }; + else + return { + message: '¡El ticket a sido declinado', + }; + }) + .catch((err) => { + throw new Error('No fue posible validar el ticket. ' + err); + }); }; module.exports = validarTicket; diff --git a/server/db/tablas/Inscripcion.js b/server/db/tablas/Inscripcion.js index 27b0bca..4ff3165 100644 --- a/server/db/tablas/Inscripcion.js +++ b/server/db/tablas/Inscripcion.js @@ -22,6 +22,10 @@ Inscripcion.init( type: DataTypes.BOOLEAN, defaultValue: 0, }, + motivo: { + type: DataTypes.STRING(100), + defaultValue: null, + }, folio: { type: DataTypes.STRING(10), allowNull: true, diff --git a/server/helper/correo.js b/server/helper/correo.js index ccd4426..0dcd256 100644 --- a/server/helper/correo.js +++ b/server/helper/correo.js @@ -1,13 +1,19 @@ const correoInscripciones = () => ({ subject: `Inscripción a CEDETEC`, msj: `Estimado usuario, su inscripción se realizo con éxito. - +

Estimado Usuario

- Para poder hacer uso de las instalaciones de CEDETEC, por favor confirma tu inscripción en el el siguiente link. + Su inscripción esta sujeta a revisión, es necesario revisar los datos que registro en el sistema.

- KALINGA +

Te sugerimos guardar tu ticket para cualquier aclaración

+

Por el momento podras hacer tu confirmacion en KALINGA

+ +

En caso de recibir un correo con el asunto Inscripción declinada se cancelara el servicio y no podras hacer uso de los servicios

+ +

Atentamente

+

Atención Usuarios DSC

`, }); diff --git a/server/uploads/reporte.csv b/server/uploads/reporte.csv index 152f5d5..c1167ac 100644 --- a/server/uploads/reporte.csv +++ b/server/uploads/reporte.csv @@ -1,2 +1,2 @@ -numero_cuenta,id_area,folio,monto,hizo_pago,fecha_inscripcion -419085500,1,99999,20,true,02/26/2022 +numeroCuenta,validacion,folio,monto,hizoPago,fechaInscripcion,idArea +419085500,2,44,555,true,03/17/2022,1