From 344427da458857a3896dad0853d55a2d4c96dfd2 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 13 Nov 2024 13:46:40 +0100 Subject: [PATCH] feat: refs #8151 moveExpeditions --- .../back/methods/expedition/moveExpeditions.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/modules/ticket/back/methods/expedition/moveExpeditions.js b/modules/ticket/back/methods/expedition/moveExpeditions.js index 1c6689912..3e9c95ec6 100644 --- a/modules/ticket/back/methods/expedition/moveExpeditions.js +++ b/modules/ticket/back/methods/expedition/moveExpeditions.js @@ -80,11 +80,19 @@ module.exports = Self => { const expeditionUpdated = expeditionToUpdate.updateAttribute('ticketFk', ticket.id, myOptions); promises.push(expeditionUpdated); } - await Promise.all(promises); + await models.Ticket.updateAll({id: ticket.id}, {packages: promises.length}, myOptions); + const state = await models.State.findOne({ + where: {code: 'PACKED'} + }, myOptions); + + await models.Ticket.state(ctx, { + ticketFk: ticket.id, + stateFk: state.id, + userFk: ctx.req.accessToken.userId + }, myOptions); if (tx) await tx.commit(); - return ticket; } catch (e) { if (tx) await tx.rollback();