Inscripcion sin ticket
This commit is contained in:
@@ -24,28 +24,34 @@ const inscripcion = async (body, file) => {
|
||||
where: { idUsuario, idArea },
|
||||
}).then((res) => {
|
||||
if (res) throw new Error('Ya estas registrado en esta área');
|
||||
return Inscripcion.create({
|
||||
idUsuario,
|
||||
confirmacion: true,
|
||||
folio: body.folio,
|
||||
monto: body.monto,
|
||||
idArea,
|
||||
fechaInscripcion: ahora.format(),
|
||||
fechaTicket: body.fechaTicket,
|
||||
rutaTicket: file.path,
|
||||
});
|
||||
if (file) {
|
||||
return Inscripcion.create({
|
||||
idUsuario,
|
||||
folio,
|
||||
monto: body.monto,
|
||||
idArea,
|
||||
fechaInscripcion: ahora.format(),
|
||||
fechaTicket: body.fechaTicket,
|
||||
rutaTicket: file.path,
|
||||
});
|
||||
} else {
|
||||
return Inscripcion.create({
|
||||
idUsuario,
|
||||
idArea,
|
||||
fechaInscripcion: ahora.format(),
|
||||
});
|
||||
}
|
||||
});
|
||||
})
|
||||
.then(
|
||||
(res) => (
|
||||
fs.renameSync(file.path, file.path + '.' + file.mimetype.split('/')[1]),
|
||||
{
|
||||
message: '¡La inscripción se realizo de manera correcta!',
|
||||
}
|
||||
)
|
||||
)
|
||||
.then((res) => {
|
||||
if (file)
|
||||
fs.renameSync(file.path, file.path + '.' + file.mimetype.split('/')[1]);
|
||||
})
|
||||
.then((res) => ({
|
||||
message: '¡La inscripción se realizo de manera correcta!',
|
||||
}))
|
||||
.catch((err) => {
|
||||
eliminarArchivo(file.path);
|
||||
if (file) eliminarArchivo(file.path);
|
||||
throw new Error('No es posible realizar esta inscripción. ' + err);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -22,6 +22,7 @@ Inscripcion.init(
|
||||
confirmacion: {
|
||||
type: DataTypes.BOOLEAN,
|
||||
allowNull: false,
|
||||
defaultValue: false,
|
||||
},
|
||||
folio: {
|
||||
type: DataTypes.STRING(5),
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 86 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 998 KiB |
Reference in New Issue
Block a user