Skip to content

Commit 15e71b1

Browse files
committed
Fix type error in Creditmemo qty validator
1 parent 50e9158 commit 15e71b1

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

app/code/Magento/Sales/Model/Order/Creditmemo/Validation/QuantityValidator.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,16 +132,17 @@ private function validateTotalQuantityRefundable(
132132
);
133133
}
134134
$orderItem = $orderItemsById[$item->getOrderItemId()];
135+
$qtyRequested = (float)$item->getQty();
135136

136-
if (!$this->isValidDecimalRefundQty($orderItem->getIsQtyDecimal(), $item->getQty())) {
137+
if (!$this->isValidDecimalRefundQty($orderItem->getIsQtyDecimal(), $qtyRequested)) {
137138
return __(
138139
'We found an invalid quantity to refund item "%1".',
139140
$orderItem->getSku()
140141
);
141142
}
142143

143-
if (!$this->canRefundItem($orderItem, $item->getQty(), $invoiceQtysRefundLimits) ||
144-
!$this->isQtyAvailable($orderItem, $item->getQty())
144+
if (!$this->canRefundItem($orderItem, $qtyRequested, $invoiceQtysRefundLimits) ||
145+
!$this->isQtyAvailable($orderItem, $qtyRequested)
145146
) {
146147
return __(
147148
'The quantity to creditmemo must not be greater than the unrefunded quantity'

app/code/Magento/Sales/Test/Unit/Model/Order/Creditmemo/Validation/QuantityValidatorTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,17 @@ public static function dataProviderForValidateQty()
284284
'isQtyDecimalAllowed' => false,
285285
'isAllowZeroGrandTotal' => true
286286
],
287+
[
288+
'orderId' => 1,
289+
'orderItemId' => 1,
290+
'qtyToRequest' => '1.0000',
291+
'qtyToRefund' => '1.0000',
292+
'sku',
293+
'total' => 15,
294+
'expected' => [],
295+
'isQtyDecimalAllowed' => false,
296+
'isAllowZeroGrandTotal' => true
297+
],
287298
[
288299
'orderId' => 1,
289300
'orderItemId' => 1,

0 commit comments

Comments
 (0)