actualizacion del ticket
This commit is contained in:
@@ -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;
|
||||
Reference in New Issue
Block a user