endponit de impresiones y tabla

This commit is contained in:
Andres2908
2022-05-06 01:57:46 -05:00
parent b1ff83b576
commit 10dc4a0e3c
5 changed files with 103 additions and 10 deletions
+39
View File
@@ -0,0 +1,39 @@
const moment = require('moment');
const fs = require('fs');
const {
validarNumeroEntero,
validarNumero,
validarNumeroCuenta,
} = require('../../helper/validar');
const dbPath = '../../db/tablas';
const Impresion = require('../../db/tablas/Impresion');
const Inscripcion = require(`${dbPath}/Inscripcion`);
const inscripcion = async (body, file) => {
const idUsuario = validarNumeroEntero(body.idUsuario, 'id Usuario', true);
const folio = validarNumero(body.folio, 'folio', true, 6);
const monto = validarNumero(body.monto, 'monto', true);
const fechaTicket = body.fechaTicket;
return Inscripcion.findOne({
where: { folio, cancelacion: 0 },
})
.then((res) => {
if (res) throw new Error('Este folio ya fue utilizado');
return Impresion.create({
idUsuario,
folio,
monto,
fechaTicket,
});
})
.then((res) => ({
message:
'Se ah registrado correctamente tu ticket, ahora puedes hacer uso del servicio de impresiones.',
}))
.catch((err) => {
throw new Error('No es posible realizar esta operación. ' + err);
});
};
module.exports = inscripcion;
@@ -68,14 +68,14 @@ const inscripcion = async (body, file) => {
.then((res) => {
if (file)
fs.renameSync(file.path, file.path + '.' + file.mimetype.split('/')[1]);
usuarioInscrito(numeroCuenta, idArea);
agregarRecibo(
folio,
monto,
moment(fechaTicket).format('L'),
numeroCuenta
);
agregarDetalleServicio(monto, numeroCuenta);
// usuarioInscrito(numeroCuenta, idArea);
// agregarRecibo(
// folio,
// monto,
// moment(fechaTicket).format('L'),
// numeroCuenta
// );
// agregarDetalleServicio(monto, numeroCuenta);
return gmail(correo.subject, email, correo.msj);
})
.then((res) => ({