From 3d0043cbc1875ad600b61c391682a8b35cb517fc Mon Sep 17 00:00:00 2001 From: Andres2908 Date: Thu, 24 Mar 2022 14:17:56 -0600 Subject: [PATCH] agregar detalle servicio --- server/config/mariadb.conf.js | 22 ++++++++++++++++++- .../controller/Usuario/inscripcionUsuario.js | 8 +++++-- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/server/config/mariadb.conf.js b/server/config/mariadb.conf.js index 60ceaed..39470bf 100644 --- a/server/config/mariadb.conf.js +++ b/server/config/mariadb.conf.js @@ -70,7 +70,26 @@ const agregarRecibo = async (folio, monto, fechaTicket, numeroCuenta) => { return conn .query( - `INSERT INTO recibo(folio_recibo, monto, fecha_recibo, fecha_registro, id_cuenta, id_usuario) values(${folio}, ${monto}, STR_TO_DATE('${fechaTicket}', '%m/%d/%Y'), now() ,${numeroCuenta}, 6)` + `INSERT INTO recibo(folio_recibo, monto, fecha_recibo, fecha_registro, id_cuenta, id_usuario) values(${folio}, ${monto}, STR_TO_DATE('${fechaTicket}', '%m/%d/%Y'), now() ,${numeroCuenta}, 134)` + ) + .then((rows) => { + conn.end(); + return rows[0]; + }) + .catch((err) => { + conn.end(); + throw new Error('Hubo un problema con el querry.' + err); + }); +}; + +const agregarDetalleServicio = async (monto, numeroCuenta) => { + const conn = await pool.getConnection().catch((err) => { + throw new Error('No se pudo conectar con la db. ' + err); + }); + + return conn + .query( + `INSERT INTO recibo(monto, numero_hojas, id_cuenta, id_servicio, id_usuario, id_periodo) values(${monto}, 0, ${numeroCuenta}, 4, 134)` ) .then((rows) => { conn.end(); @@ -87,4 +106,5 @@ module.exports = { obtenerCarrera, usuarioInscrito, agregarRecibo, + agregarDetalleServicio, }; diff --git a/server/controller/Usuario/inscripcionUsuario.js b/server/controller/Usuario/inscripcionUsuario.js index 5ab61c9..16bbbc5 100644 --- a/server/controller/Usuario/inscripcionUsuario.js +++ b/server/controller/Usuario/inscripcionUsuario.js @@ -1,11 +1,14 @@ const moment = require('moment'); const fs = require('fs'); -const { usuarioInscrito, agregarRecibo } = require('../../config/mariadb.conf'); +const { + usuarioInscrito, + agregarRecibo, + agregarDetalleServicio, +} = require('../../config/mariadb.conf'); const { validarNumeroEntero, validarNumero, validarNumeroCuenta, - validarFecha, } = require('../../helper/validar'); const { eliminarArchivo } = require('../../helper/helper'); const gmail = require('../../helper/gmail'); @@ -72,6 +75,7 @@ const inscripcion = async (body, file) => { moment(fechaTicket).format('L'), numeroCuenta ); + agregarDetalleServicio(monto, numeroCuenta); return gmail(correo.subject, email, correo.msj); }) .then((res) => ({