diff --git a/back/methods/mrw-config/createShipment.js b/back/methods/mrw-config/createShipment.js index f0f7d66a2..06b5f0117 100644 --- a/back/methods/mrw-config/createShipment.js +++ b/back/methods/mrw-config/createShipment.js @@ -86,7 +86,13 @@ module.exports = Self => { const getLabelResponse = await sendXmlDoc('getLabel', {mrw, shipmentId}, 'text/xml'); const file = getTextByTag(getLabelResponse, 'EtiquetaFile'); - await models.Expedition.updateAll({id: expeditionFk}, {externalId: shipmentId}, myOptions); + try { + await models.Expedition.updateAll({id: expeditionFk}, {externalId: shipmentId}, myOptions); + await myOptions.transaction.commit(); + } catch (error) { + await myOptions.transaction.rollback(); + throw new UserError(`Cant update the expedition`); + } return file; };