![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/cartforge.co/vendor/magento/module-sales/Controller/Adminhtml/Order/Invoice/ |
<?php /** * * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ namespace Magento\Sales\Controller\Adminhtml\Order\Invoice; class Cancel extends \Magento\Sales\Controller\Adminhtml\Invoice\AbstractInvoice\View { /** * Cancel invoice action * * @return \Magento\Framework\Controller\ResultInterface */ public function execute() { $invoice = $this->getInvoice(); if (!$invoice) { /** @var \Magento\Backend\Model\View\Result\Forward $resultForward */ $resultForward = $this->resultForwardFactory->create(); return $resultForward->forward('noroute'); } try { $invoice->cancel(); $invoice->getOrder()->setIsInProcess(true); $this->_objectManager->create( \Magento\Framework\DB\Transaction::class )->addObject( $invoice )->addObject( $invoice->getOrder() )->save(); $this->messageManager->addSuccessMessage(__('You canceled the invoice.')); } catch (\Magento\Framework\Exception\LocalizedException $e) { $this->messageManager->addErrorMessage($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addErrorMessage(__('Invoice canceling error')); } /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ $resultRedirect = $this->resultRedirectFactory->create(); $resultRedirect->setPath('sales/*/view', ['invoice_id' => $invoice->getId()]); return $resultRedirect; } }