From 50e9158df4c83affbaa5f08a0a2a4212680ad034 Mon Sep 17 00:00:00 2001 From: Maximilian Fickers Date: Tue, 18 Nov 2025 14:50:48 +0100 Subject: [PATCH 1/2] Fix type error for item qty when refunding an invoice --- app/code/Magento/Sales/Model/Order/CreditmemoFactory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Sales/Model/Order/CreditmemoFactory.php b/app/code/Magento/Sales/Model/Order/CreditmemoFactory.php index c86400d178d70..e45e62b569a6c 100644 --- a/app/code/Magento/Sales/Model/Order/CreditmemoFactory.php +++ b/app/code/Magento/Sales/Model/Order/CreditmemoFactory.php @@ -138,7 +138,7 @@ public function createByInvoice(\Magento\Sales\Model\Order\Invoice $invoice, arr $qty = min( $this->getQtyToRefund($orderItem, $qtyList, $invoiceRefundLimitsQtyList), - $invoiceItem->getQty() + (float)$invoiceItem->getQty() ); $totalQty += $qty; $item = $this->convertor->itemToCreditmemoItem($orderItem); From 15e71b1f36c3dcadb49e7db0bb104ba4d4109d98 Mon Sep 17 00:00:00 2001 From: Maximilian Fickers Date: Wed, 19 Nov 2025 14:18:11 +0100 Subject: [PATCH 2/2] Fix type error in Creditmemo qty validator --- .../Order/Creditmemo/Validation/QuantityValidator.php | 7 ++++--- .../Creditmemo/Validation/QuantityValidatorTest.php | 11 +++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/Sales/Model/Order/Creditmemo/Validation/QuantityValidator.php b/app/code/Magento/Sales/Model/Order/Creditmemo/Validation/QuantityValidator.php index ad09ab54dfcd3..fc150943a1317 100644 --- a/app/code/Magento/Sales/Model/Order/Creditmemo/Validation/QuantityValidator.php +++ b/app/code/Magento/Sales/Model/Order/Creditmemo/Validation/QuantityValidator.php @@ -132,16 +132,17 @@ private function validateTotalQuantityRefundable( ); } $orderItem = $orderItemsById[$item->getOrderItemId()]; + $qtyRequested = (float)$item->getQty(); - if (!$this->isValidDecimalRefundQty($orderItem->getIsQtyDecimal(), $item->getQty())) { + if (!$this->isValidDecimalRefundQty($orderItem->getIsQtyDecimal(), $qtyRequested)) { return __( 'We found an invalid quantity to refund item "%1".', $orderItem->getSku() ); } - if (!$this->canRefundItem($orderItem, $item->getQty(), $invoiceQtysRefundLimits) || - !$this->isQtyAvailable($orderItem, $item->getQty()) + if (!$this->canRefundItem($orderItem, $qtyRequested, $invoiceQtysRefundLimits) || + !$this->isQtyAvailable($orderItem, $qtyRequested) ) { return __( 'The quantity to creditmemo must not be greater than the unrefunded quantity' diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Creditmemo/Validation/QuantityValidatorTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Creditmemo/Validation/QuantityValidatorTest.php index 1b1d7ef2ec48d..7f500dc303c00 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Creditmemo/Validation/QuantityValidatorTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Creditmemo/Validation/QuantityValidatorTest.php @@ -284,6 +284,17 @@ public static function dataProviderForValidateQty() 'isQtyDecimalAllowed' => false, 'isAllowZeroGrandTotal' => true ], + [ + 'orderId' => 1, + 'orderItemId' => 1, + 'qtyToRequest' => '1.0000', + 'qtyToRefund' => '1.0000', + 'sku', + 'total' => 15, + 'expected' => [], + 'isQtyDecimalAllowed' => false, + 'isAllowZeroGrandTotal' => true + ], [ 'orderId' => 1, 'orderItemId' => 1,