actualizacion del ticket

This commit is contained in:
Andres2908
2022-03-15 18:26:51 -06:00
parent c5f488a7c9
commit 52a6cb614b
6 changed files with 98 additions and 7 deletions
@@ -0,0 +1,39 @@
const dbPath = '../../db/tablas';
const { validarNumeroEntero } = require('../../helper/validar');
const Inscripcion = require(`${dbPath}/Inscripcion`);
const actualizarTicket = async (body) => {
const idInscripcion = validarNumeroEntero(
body.idInscripcion,
'id Inscripcion',
true
);
return Inscripcion.findOne({
where: { idInscripcion },
})
.then((res) => {
if (!res) throw new Error('No pudimos encontrar este ticket.');
return Inscripcion.update(
{
folio: body.folio,
monto: body.monto,
fechaTicket: body.fechaTicket,
},
{
where: {
idInscripcion,
},
}
);
})
.then((res) => ({
message:
'¡ Los datos de la inscripción fueron actualizados de forma correcta !',
}))
.catch((err) => {
throw new Error('No fue posible validar el ticket. ' + err);
});
};
module.exports = actualizarTicket;