Skip to content

Commit 0da0ebc

Browse files
author
Anna Bukatar
committed
ACP2E-1155: Refunding Issue Rest API
1 parent bf4ac0e commit 0da0ebc

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

app/code/Magento/Sales/Model/Order/Invoice/Validation/CanRefund.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Magento\Sales\Api\OrderRepositoryInterface;
1313
use Magento\Sales\Model\Order\Invoice;
1414
use Magento\Sales\Model\ValidatorInterface;
15+
use Magento\Framework\App\Config\ScopeConfigInterface;
1516
use Magento\Framework\App\ObjectManager;
1617

1718
class CanRefund implements ValidatorInterface
@@ -27,23 +28,25 @@ class CanRefund implements ValidatorInterface
2728
private $orderRepository;
2829

2930
/**
30-
* @var ObjectManager
31+
* @var ScopeConfigInterface
3132
*/
32-
private $objectManager;
33+
private $scopeConfig;
3334

3435
/**
3536
* CanRefund constructor.
3637
*
3738
* @param OrderPaymentRepositoryInterface $paymentRepository
3839
* @param OrderRepositoryInterface $orderRepository
40+
* @param ScopeConfigInterface|null $scopeConfig
3941
*/
4042
public function __construct(
4143
OrderPaymentRepositoryInterface $paymentRepository,
42-
OrderRepositoryInterface $orderRepository
44+
OrderRepositoryInterface $orderRepository,
45+
?ScopeConfigInterface $scopeConfig = null
4346
) {
44-
$this->objectManager = ObjectManager::getInstance();
4547
$this->paymentRepository = $paymentRepository;
4648
$this->orderRepository = $orderRepository;
49+
$this->scopeConfig = $scopeConfig ?? ObjectManager::getInstance()->get(ScopeConfigInterface::class);
4750
}
4851

4952
/**
@@ -89,7 +92,7 @@ private function isPaymentAllowRefund(InvoiceInterface $invoice)
8992
*/
9093
private function isGrandTotalEnoughToRefund(InvoiceInterface $entity)
9194
{
92-
$isAllowedZeroGrandTotal = $this->objectManager->get(ScopeConfigInterface::class)->getValue(
95+
$isAllowedZeroGrandTotal = $this->scopeConfig->getValue(
9396
'sales/zerograndtotal_creditmemo/allow_zero_grandtotal',
9497
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
9598
);

app/code/Magento/Sales/Model/Order/Validation/CanRefund.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66
namespace Magento\Sales\Model\Order\Validation;
77

8+
use Magento\Framework\App\Config\ScopeConfigInterface;
89
use Magento\Framework\App\ObjectManager;
910
use Magento\Framework\Pricing\PriceCurrencyInterface;
1011
use Magento\Sales\Api\Data\OrderInterface;
@@ -19,20 +20,22 @@ class CanRefund implements ValidatorInterface
1920
private $priceCurrency;
2021

2122
/**
22-
* @var ObjectManager
23+
* @var ScopeConfigInterface
2324
*/
24-
private $objectManager;
25+
private $scopeConfig;
2526

2627
/**
2728
* CanRefund constructor.
2829
*
2930
* @param PriceCurrencyInterface $priceCurrency
31+
* @param ScopeConfigInterface|null $scopeConfig
3032
*/
3133
public function __construct(
32-
PriceCurrencyInterface $priceCurrency
34+
PriceCurrencyInterface $priceCurrency,
35+
?ScopeConfigInterface $scopeConfig = null
3336
) {
34-
$this->objectManager = ObjectManager::getInstance();
3537
$this->priceCurrency = $priceCurrency;
38+
$this->scopeConfig = $scopeConfig ?? ObjectManager::getInstance()->get(ScopeConfigInterface::class);
3639
}
3740

3841
/**
@@ -67,7 +70,7 @@ public function validate($entity)
6770
*/
6871
private function isTotalPaidEnoughForRefund(OrderInterface $order)
6972
{
70-
$isAllowedZeroGrandTotal = $this->objectManager->get(ScopeConfigInterface::class)->getValue(
73+
$isAllowedZeroGrandTotal = $this->scopeConfig->getValue(
7174
'sales/zerograndtotal_creditmemo/allow_zero_grandtotal',
7275
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
7376
);

0 commit comments

Comments
 (0)