From c1c64d0f89dcbc51e34c2b86318da14ddbdea875 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 26 Feb 2024 13:39:57 +0100 Subject: [PATCH] fix: refs #6184 saveSign --- modules/ticket/back/methods/ticket/saveSign.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/modules/ticket/back/methods/ticket/saveSign.js b/modules/ticket/back/methods/ticket/saveSign.js index 58599716a..ea9f715a9 100644 --- a/modules/ticket/back/methods/ticket/saveSign.js +++ b/modules/ticket/back/methods/ticket/saveSign.js @@ -34,6 +34,8 @@ module.exports = Self => { const myOptions = {userId: ctx.req.accessToken.userId}; let tx; let ticket; + let dms; + let isSignUploaded; let externalTickets = []; if (typeof options == 'object') @@ -80,8 +82,8 @@ module.exports = Self => { description: `Firma del cliente - Ruta ${ticket.route().id}`, hasFile: true }; - const dms = await models.Dms.uploadFile(ctxUploadFile, myOptions); - await models.TicketDms.create({ticketFk: ticket.id, dmsFk: dms[0].id}, myOptions); + dms = await models.Dms.uploadFile(ctxUploadFile, myOptions); + isSignUploaded = true; } try { @@ -130,7 +132,9 @@ module.exports = Self => { throw new UserError('Ticket is already signed'); if (location) await setLocation(ticketId); - if (!await hasSignDms(ticketId)) await createGestDoc(ticketId); + if (!await hasSignDms(ticketId) && !isSignUploaded) + await createGestDoc(ticketId); + await models.TicketDms.create({ticketFk: ticket.id, dmsFk: dms[0].id}, myOptions); await ticket.updateAttribute('isSigned', true, myOptions); const deliveryState = await models.State.findOne({