diff --git a/vendor/magento/module-customer-balance/Model/Creditmemo/Balance.php b/vendor/magento/module-customer-balance/Model/Creditmemo/Balance.php index 2e3ef806b34..71f927501bb 100644 --- a/vendor/magento/module-customer-balance/Model/Creditmemo/Balance.php +++ b/vendor/magento/module-customer-balance/Model/Creditmemo/Balance.php @@ -73,14 +73,13 @@ class Balance $order->setCustomerBalanceRefunded( $order->getCustomerBalanceRefunded() + $customerBalanceRefunded ); + $this->orderRepository->save($order); $status = $order->getConfig()->getStateDefaultStatus($order->getState()); $comment = __( 'We refunded %1 to Store Credit', $order->getBaseCurrency()->formatTxt($customerBalanceRefunded) ); $order->addCommentToStatusHistory($comment, $status, false); - $this->orderRepository->save($order); - $websiteId = $this->storeManager->getStore($order->getStoreId())->getWebsiteId(); $this->balanceFactory->create() diff --git a/vendor/magento/module-customer-balance/Plugin/CreditMemoResolver.php b/vendor/magento/module-customer-balance/Plugin/CreditMemoResolver.php index 5d77925ebfe..69cbb29adc5 100644 --- a/vendor/magento/module-customer-balance/Plugin/CreditMemoResolver.php +++ b/vendor/magento/module-customer-balance/Plugin/CreditMemoResolver.php @@ -63,7 +63,8 @@ class CreditMemoResolver return true; } - if ($this->comparator->equal((float)$subject->getBaseTotalPaid(), $totalRefunded)) { + // If total invoiced is equal to total refunded amount then CreditMemo can not be created anymore + if ($this->comparator->equal($totalRefunded, $totalInvoiced)) { return false; }