diff --git a/back/methods/mrw-config/cancelShipment.js b/back/methods/mrw-config/cancelShipment.js index 98aa8be39..e96d6d694 100644 --- a/back/methods/mrw-config/cancelShipment.js +++ b/back/methods/mrw-config/cancelShipment.js @@ -24,12 +24,13 @@ module.exports = Self => { Self.cancelShipment = async expeditionFk => { const models = Self.app.models; - const mrw = await models.MrwConfig.findOne(); const {externalId} = await models.Expedition.findById(expeditionFk); const clientType = await models.MrwConfig.getClientType(expeditionFk); const template = fs.readFileSync(__dirname + '/cancelShipment.ejs', 'utf-8'); const renderedXml = ejs.render(template, {mrw, externalId, clientType}); + + await Self.rawSql('CALL util.debugAdd(?,?);', ['cancelShipment', renderedXml]); const response = await axios.post(mrw.url, renderedXml, { headers: { 'Content-Type': 'application/soap+xml; charset=utf-8' @@ -37,12 +38,11 @@ module.exports = Self => { }); const xmlString = response.data; + await Self.rawSql('CALL util.debugAdd(?,?);', ['cancelShipmentResponse', xmlString]); const parser = new DOMParser(); const xmlDoc = parser.parseFromString(xmlString, 'text/xml'); - await Self.rawSql('CALL util.debugAdd(?,?);', ['cancelShipment', xmlDoc]); - const result = xmlDoc.getElementsByTagName('Mensaje')[0].textContent; - return result.toLowerCase().includes('se ha cancelado correctamente'); + return ['no se ha encontrado', 'se ha cancelado correctamente'].some(res => result.toLowerCase().includes(res)); }; }; diff --git a/modules/ticket/back/methods/expedition/deleteExpeditions.js b/modules/ticket/back/methods/expedition/deleteExpeditions.js index 75993a485..267811d25 100644 --- a/modules/ticket/back/methods/expedition/deleteExpeditions.js +++ b/modules/ticket/back/methods/expedition/deleteExpeditions.js @@ -52,7 +52,8 @@ module.exports = Self => { const deletedExpedition = await models.Expedition.destroyById(expeditionId); deletedExpeditions.push(deletedExpedition); - } catch (e) { + } catch (error) { + console.error('error: ', error); notDeletedExpeditions.push(expeditionId); } }