Commit 80609ed5 authored by Ana Rute Mendes's avatar Ana Rute Mendes 🌈

shipping: reposition where to call item details from snipe-it

make sure it's called only when the ticket has its status changed
parent 54dddba0
...@@ -397,13 +397,31 @@ final class ManiphestTransactionEditor ...@@ -397,13 +397,31 @@ final class ManiphestTransactionEditor
case ManiphestTaskStatusTransaction::TRANSACTIONTYPE: case ManiphestTaskStatusTransaction::TRANSACTIONTYPE:
$new_status = $xaction->getNewValue(); $new_status = $xaction->getNewValue();
// CCU: create Item in the inventory system if it's a Purchase request and // CCU: create Item in the inventory system if it's a Purchase or
// its status was changed to "resolved" (Closed) and it's not a preview // Shipping request and its status was changed to "resolved" (Closed)
// and it's not a preview
if (!$this->getIsNewObject() && !$this->getIsPreview()) { if (!$this->getIsNewObject() && !$this->getIsPreview()) {
try { if ($object->getSubtype() == 'purchasing') {
$asset_transactions = $snipe_api->createAssetItem($new_status, $object, $xactions); try {
} catch (Exception $e) { $asset_transactions = $snipe_api->createAssetItem($new_status, $object, $xactions);
$asset_transactions = []; } catch (Exception $e) {
$asset_transactions = [];
}
}
// CCU: if it's a Shipping Request, check if it has an asset item
// in Snipe-IT and automatically fill in some fields.
if ($object->getSubtype() == 'shipping') {
try {
$snipe_api->fetchAssetItem($object, $xactions);
} catch (Exception $e) {
$this->moreValidationErrors[] = new PhabricatorApplicationTransactionValidationError(
PhabricatorTransactions::TYPE_EDGE,
null,
pht('An error ocurred while editing the item in Snipe-IT, please talk with the tools team.'),
null
);
}
} }
} }
break; break;
...@@ -615,21 +633,6 @@ final class ManiphestTransactionEditor ...@@ -615,21 +633,6 @@ final class ManiphestTransactionEditor
} }
} }
// CCU: if it's a Shipping Request, check if it has an asset item
// in Snipe-IT and automatically fill in some fields.
if ($subtype == 'shipping') {
try {
$snipe_api->fetchAssetItem($object, $xactions);
} catch (Exception $e) {
$this->moreValidationErrors[] = new PhabricatorApplicationTransactionValidationError(
PhabricatorTransactions::TYPE_EDGE,
null,
pht('An error ocurred while editing the item in Snipe-IT, please talk with the tools team.'),
null
);
}
}
return $results; return $results;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment