-
-
Notifications
You must be signed in to change notification settings - Fork 450
rector: CombineIfRector
#4880
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
rector: CombineIfRector
#4880
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -160,19 +160,17 @@ public function canReturnToStock() | |
*/ | ||
public function canReturnItemsToStock() | ||
{ | ||
if (is_null($this->_canReturnToStock)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh boy.. setting something in a if and also in a setter. |
||
if ($this->_canReturnToStock = Mage::getStoreConfig(Mage_CatalogInventory_Model_Stock_Item::XML_PATH_CAN_SUBTRACT)) { | ||
$canReturnToStock = false; | ||
foreach ($this->getCreditmemo()->getAllItems() as $item) { | ||
$product = Mage::getModel('catalog/product')->load($item->getOrderItem()->getProductId()); | ||
if ($product->getId() && $product->getStockItem()->getManageStock()) { | ||
$item->setCanReturnToStock($canReturnToStock = true); | ||
} else { | ||
$item->setCanReturnToStock(false); | ||
} | ||
if (is_null($this->_canReturnToStock) && $this->_canReturnToStock = Mage::getStoreConfig(Mage_CatalogInventory_Model_Stock_Item::XML_PATH_CAN_SUBTRACT)) { | ||
$canReturnToStock = false; | ||
foreach ($this->getCreditmemo()->getAllItems() as $item) { | ||
$product = Mage::getModel('catalog/product')->load($item->getOrderItem()->getProductId()); | ||
if ($product->getId() && $product->getStockItem()->getManageStock()) { | ||
$item->setCanReturnToStock($canReturnToStock = true); | ||
} else { | ||
$item->setCanReturnToStock(false); | ||
} | ||
$this->getCreditmemo()->getOrder()->setCanReturnToStock($this->_canReturnToStock = $canReturnToStock); | ||
} | ||
$this->getCreditmemo()->getOrder()->setCanReturnToStock($this->_canReturnToStock = $canReturnToStock); | ||
} | ||
return $this->_canReturnToStock; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,18 +58,12 @@ public function __construct() | |
|
||
$orderPayment = $this->getInvoice()->getOrder()->getPayment(); | ||
|
||
if ($this->_isAllowedAction('creditmemo') && $this->getInvoice()->getOrder()->canCreditmemo()) { | ||
if (($orderPayment->canRefundPartialPerInvoice() | ||
&& $this->getInvoice()->canRefund() | ||
&& $orderPayment->getAmountPaid() > $orderPayment->getAmountRefunded()) | ||
|| ($orderPayment->canRefund() && !$this->getInvoice()->getIsUsedForRefund()) | ||
) { | ||
$this->_addButton('capture', [ // capture? | ||
'label' => Mage::helper('sales')->__('Credit Memo'), | ||
'class' => 'go', | ||
'onclick' => Mage::helper('core/js')->getSetLocationJs($this->getCreditMemoUrl()), | ||
]); | ||
} | ||
if ($this->_isAllowedAction('creditmemo') && $this->getInvoice()->getOrder()->canCreditmemo() && ($orderPayment->canRefundPartialPerInvoice() && $this->getInvoice()->canRefund() && $orderPayment->getAmountPaid() > $orderPayment->getAmountRefunded() || $orderPayment->canRefund() && !$this->getInvoice()->getIsUsedForRefund())) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is also way too long to process. Can refactor do these in a seperate line? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll check all long lines later. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed. It would be nice if after a certain character cutoff Rector could stack conditions vertically for better readability. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I hoped php-cs-fixer would jump in to fix it, but seems i have to do it manually. |
||
$this->_addButton('capture', [ // capture? | ||
'label' => Mage::helper('sales')->__('Credit Memo'), | ||
'class' => 'go', | ||
'onclick' => Mage::helper('core/js')->getSetLocationJs($this->getCreditMemoUrl()), | ||
]); | ||
} | ||
|
||
if ($this->_isAllowedAction('capture') && $this->getInvoice()->canCapture()) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a long one. Also, it can simplify to
return $condition
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. This doesnt enhance readability.