16 private $returnProcessor;
21 private $creditmemoRepository;
26 private $orderRepository;
31 private $invoiceRepository;
36 private $stockConfiguration;
50 \
Magento\Sales\Api\InvoiceRepositoryInterface $invoiceRepository,
53 $this->returnProcessor = $returnProcessor;
54 $this->creditmemoRepository = $creditmemoRepository;
57 $this->stockConfiguration = $stockConfiguration;
74 \
Magento\Sales\Api\RefundInvoiceInterface $refundService,
80 $appendComment =
false,
81 \
Magento\Sales\Api\Data\CreditmemoCommentCreationInterface $comment =
null,
84 $invoice = $this->invoiceRepository->get($invoiceId);
87 $returnToStockItems = [];
89 &&
$arguments->getExtensionAttributes() !==
null 90 &&
$arguments->getExtensionAttributes()->getReturnToStockItems() !== null
92 $returnToStockItems =
$arguments->getExtensionAttributes()->getReturnToStockItems();
94 $isAutoReturn = $this->stockConfiguration->isAutoReturnEnabled();
95 if ($isAutoReturn || !empty($returnToStockItems)) {
96 $creditmemo = $this->creditmemoRepository->get($resultEntityId);
97 $this->returnProcessor->execute(
$creditmemo,
$order, $returnToStockItems, $isAutoReturn);
99 return $resultEntityId;
afterExecute(\Magento\Sales\Api\RefundInvoiceInterface $refundService, $resultEntityId, $invoiceId, array $items=[], $isOnline=false, $notify=false, $appendComment=false, \Magento\Sales\Api\Data\CreditmemoCommentCreationInterface $comment=null, \Magento\Sales\Api\Data\CreditmemoCreationArgumentsInterface $arguments=null)
__construct(\Magento\SalesInventory\Model\Order\ReturnProcessor $returnProcessor, \Magento\Sales\Api\CreditmemoRepositoryInterface $creditmemoRepository, \Magento\Sales\Api\OrderRepositoryInterface $orderRepository, \Magento\Sales\Api\InvoiceRepositoryInterface $invoiceRepository, \Magento\CatalogInventory\Api\StockConfigurationInterface $stockConfiguration)