correcciones a impresiones
This commit is contained in:
@@ -1,15 +1,9 @@
|
||||
const moment = require('moment');
|
||||
const fs = require('fs');
|
||||
const {
|
||||
validarNumeroEntero,
|
||||
validarNumero,
|
||||
validarNumeroCuenta,
|
||||
} = require('../../helper/validar');
|
||||
const { validarNumeroEntero, validarNumero } = require('../../helper/validar');
|
||||
const dbPath = '../../db/tablas';
|
||||
const Impresion = require('../../db/tablas/Impresion');
|
||||
const Impresion = require(`${dbPath}/Impresion`);
|
||||
const Inscripcion = require(`${dbPath}/Inscripcion`);
|
||||
|
||||
const inscripcion = async (body, file) => {
|
||||
const impresiones = async (body) => {
|
||||
const idUsuario = validarNumeroEntero(body.idUsuario, 'id Usuario', true);
|
||||
const folio = validarNumero(body.folio, 'folio', true, 6);
|
||||
const monto = validarNumero(body.monto, 'monto', true);
|
||||
@@ -19,7 +13,16 @@ const inscripcion = async (body, file) => {
|
||||
where: { folio, cancelacion: 0 },
|
||||
})
|
||||
.then((res) => {
|
||||
if (res) throw new Error('Este folio ya fue utilizado');
|
||||
if (res)
|
||||
throw new Error('Este folio ya fue utilizado en alguna inscripción');
|
||||
return Impresion.findOne({
|
||||
where: { folio },
|
||||
}).then((res) => {
|
||||
if (res)
|
||||
throw new Error('Este folio ya fue utilizado para impresiones');
|
||||
});
|
||||
})
|
||||
.then((res) => {
|
||||
return Impresion.create({
|
||||
idUsuario,
|
||||
folio,
|
||||
@@ -28,12 +31,11 @@ const inscripcion = async (body, file) => {
|
||||
});
|
||||
})
|
||||
.then((res) => ({
|
||||
message:
|
||||
'Se ah registrado correctamente tu ticket, ahora puedes hacer uso del servicio de impresiones.',
|
||||
message: `Se a registrado correctamente tu ticket, se agregaron $${monto} a tu cuenta, ahora puedes hacer uso del servicio de impresiones.`,
|
||||
}))
|
||||
.catch((err) => {
|
||||
throw new Error('No es posible realizar esta operación. ' + err);
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = inscripcion;
|
||||
module.exports = impresiones;
|
||||
|
||||
Reference in New Issue
Block a user