From e08fb3d229485a9d0453a7e4e35cbe0a66ab44c4 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 13 Feb 2024 08:59:58 +0100 Subject: [PATCH] fix: refs #6184 Minor change --- loopback/locale/es.json | 5 +++-- modules/ticket/back/methods/ticket/saveSign.js | 11 ++++------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/loopback/locale/es.json b/loopback/locale/es.json index b48772f0d..b0eb59cd5 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -339,8 +339,9 @@ "No tickets to invoice": "No hay tickets para facturar", "This ticket already has a cmr saved": "Este ticket ya tiene un cmr guardado", "Name should be uppercase": "El nombre debe ir en mayúscula", - "Bank entity must be specified": "La entidad bancaria es obligatoria", + "Bank entity must be specified": "La entidad bancaria es obligatoria", "An email is necessary": "Es necesario un email", "You cannot update these fields": "No puedes actualizar estos campos", - "CountryFK cannot be empty": "El país no puede estar vacío" + "CountryFK cannot be empty": "El país no puede estar vacío", + "Cmr file does not exist": "El archivo del cmr no existe" } \ No newline at end of file diff --git a/modules/ticket/back/methods/ticket/saveSign.js b/modules/ticket/back/methods/ticket/saveSign.js index 0fcd41102..3718dfcda 100644 --- a/modules/ticket/back/methods/ticket/saveSign.js +++ b/modules/ticket/back/methods/ticket/saveSign.js @@ -34,8 +34,6 @@ module.exports = Self => { const myOptions = {userId: ctx.req.accessToken.userId}; let tx; let ticket; - let dms; - let gestDocCreated; if (typeof options == 'object') Object.assign(myOptions, options); @@ -86,8 +84,8 @@ module.exports = Self => { contentType: 'image/png', hasFile: true }; - dms = await models.Dms.uploadFile(ctxUploadFile, myOptions); - gestDocCreated = true; + const dms = await models.Dms.uploadFile(ctxUploadFile, myOptions); + await models.TicketDms.create({ticketFk: ticket.id, dmsFk: dms[0].id}, myOptions); } try { @@ -137,9 +135,8 @@ module.exports = Self => { throw new UserError('Ticket is already signed'); if (location) await setLocation(ticketId); - if (!await hasSignDms(ticketId) && !gestDocCreated) + if (!await hasSignDms(ticketId)) await createGestDoc(ticketId); - await models.TicketDms.create({ticketFk: ticketId, dmsFk: dms[0].id}, myOptions); await ticket.updateAttribute('isSigned', true, myOptions); const deliveryState = await models.State.findOne({ @@ -160,7 +157,7 @@ module.exports = Self => { await models.Route.cmrEmail(ctx, externalTickets); return; } catch (e) { - if (tx) await tx.rollback(); + if (tx && tx.isActive()) await tx.rollback(); throw e; } };