feat: refs #6403 add delete #2743
|
@ -13,7 +13,7 @@ module.exports = Self => {
|
||||||
required: true
|
required: true
|
||||||
}],
|
}],
|
||||||
returns: {
|
returns: {
|
||||||
type: ['object'],
|
type: 'boolean',
|
||||||
root: true
|
root: true
|
||||||
},
|
},
|
||||||
http: {
|
http: {
|
||||||
|
@ -39,6 +39,7 @@ module.exports = Self => {
|
||||||
const xmlString = response.data;
|
const xmlString = response.data;
|
||||||
const parser = new DOMParser();
|
const parser = new DOMParser();
|
||||||
const xmlDoc = parser.parseFromString(xmlString, 'text/xml');
|
const xmlDoc = parser.parseFromString(xmlString, 'text/xml');
|
||||||
return xmlDoc.getElementsByTagName('Mensaje')[0].textContent;
|
const result = xmlDoc.getElementsByTagName('Mensaje')[0].textContent;
|
||||||
pablone marked this conversation as resolved
|
|||||||
|
return result.toLowerCase().includes('se ha cancelado correctamente');
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -44,15 +44,21 @@ module.exports = Self => {
|
||||||
|
|
||||||
const expedition = await models.Expedition.findOne(filter);
|
const expedition = await models.Expedition.findOne(filter);
|
||||||
const {code} = expedition.agencyMode();
|
const {code} = expedition.agencyMode();
|
||||||
|
let isDeleted = true;
|
||||||
|
|
||||||
if (code && code.toLowerCase().substring(0, 10) == 'viaexpress') {
|
if (code?.toLowerCase()?.includes('mrw')) {
|
||||||
const isDeleted = await models.ViaexpressConfig.deleteExpedition(expeditionId);
|
const result = await models.MrwConfig.cancelShipment(expeditionId);
|
||||||
|
isDeleted = result;
|
||||||
|
}
|
||||||
|
|
||||||
if (isDeleted === 'true') {
|
if (code?.toLowerCase()?.substring(0, 10) == 'viaexpress') {
|
||||||
const deletedExpedition = await models.Expedition.destroyById(expeditionId);
|
const result = await models.ViaexpressConfig.deleteExpedition(expeditionId);
|
||||||
deletedExpeditions.push(deletedExpedition);
|
if (result !== 'true') isDeleted = false;
|
||||||
} else notDeletedExpeditions.push(expeditionId);
|
}
|
||||||
} else {
|
|
||||||
|
if (!isDeleted)
|
||||||
|
notDeletedExpeditions.push(expeditionId);
|
||||||
|
else {
|
||||||
const deletedExpedition = await models.Expedition.destroyById(expeditionId);
|
const deletedExpedition = await models.Expedition.destroyById(expeditionId);
|
||||||
deletedExpeditions.push(deletedExpedition);
|
deletedExpeditions.push(deletedExpedition);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
const [{textContent}] = xmlDoc.getElementsByTagName('Mensaje')
return textContent.toLowerCase().includes('se ha cancelado correctamente');