Merge pull request 'feat: refs #6403 add cancelShipment on deleteExpeditions' (!2747) from 6403-featDeleteMrw into master
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
Reviewed-on: #2747 Reviewed-by: Alex Moreno <alexm@verdnatura.es>
This commit is contained in:
commit
b5728b43f0
|
@ -13,7 +13,7 @@ module.exports = Self => {
|
|||
required: true
|
||||
}],
|
||||
returns: {
|
||||
type: ['object'],
|
||||
type: 'boolean',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
|
@ -39,6 +39,7 @@ module.exports = Self => {
|
|||
const xmlString = response.data;
|
||||
const parser = new DOMParser();
|
||||
const xmlDoc = parser.parseFromString(xmlString, 'text/xml');
|
||||
return xmlDoc.getElementsByTagName('Mensaje')[0].textContent;
|
||||
const [{textContent}] = xmlDoc.getElementsByTagName('Mensaje');
|
||||
return textContent.toLowerCase().includes('se ha cancelado correctamente');
|
||||
};
|
||||
};
|
||||
|
|
|
@ -44,15 +44,19 @@ module.exports = Self => {
|
|||
|
||||
const expedition = await models.Expedition.findOne(filter);
|
||||
const {code} = expedition.agencyMode();
|
||||
let isDeleted = true;
|
||||
|
||||
if (code && code.toLowerCase().substring(0, 10) == 'viaexpress') {
|
||||
const isDeleted = await models.ViaexpressConfig.deleteExpedition(expeditionId);
|
||||
if (code?.toLowerCase()?.includes('mrw'))
|
||||
isDeleted = await models.MrwConfig.cancelShipment(expeditionId);
|
||||
|
||||
if (isDeleted === 'true') {
|
||||
const deletedExpedition = await models.Expedition.destroyById(expeditionId);
|
||||
deletedExpeditions.push(deletedExpedition);
|
||||
} else notDeletedExpeditions.push(expeditionId);
|
||||
} else {
|
||||
if (code?.toLowerCase()?.substring(0, 10) == 'viaexpress') {
|
||||
const result = await models.ViaexpressConfig.deleteExpedition(expeditionId);
|
||||
if (result !== 'true') isDeleted = false;
|
||||
}
|
||||
|
||||
if (!isDeleted)
|
||||
notDeletedExpeditions.push(expeditionId);
|
||||
else {
|
||||
const deletedExpedition = await models.Expedition.destroyById(expeditionId);
|
||||
deletedExpeditions.push(deletedExpedition);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue