File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed
Model/Order/Creditmemo/Validation Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -83,6 +83,14 @@ public function validate($entity)
83
83
}
84
84
$ orderItem = $ orderItemsById [$ item ->getOrderItemId ()];
85
85
86
+ if ($ this ->isValidRefundQty ($ orderItem ->getIsQtyDecimal (), $ item ->getQty ())) {
87
+ $ messages [] =__ (
88
+ 'You cannot use decimal quantity to refund item "%1". ' ,
89
+ $ item ->getSku ()
90
+ );
91
+ continue ;
92
+ }
93
+
86
94
if (!$ this ->canRefundItem ($ orderItem , $ item ->getQty (), $ invoiceQtysRefundLimits ) ||
87
95
!$ this ->isQtyAvailable ($ orderItem , $ item ->getQty ())
88
96
) {
@@ -105,6 +113,21 @@ public function validate($entity)
105
113
return $ messages ;
106
114
}
107
115
116
+ /**
117
+ * to check the refund qty is decimal if getIsQtyDecimal is unset.
118
+ *
119
+ * @param int|null $isQtyDecimal
120
+ * @param float $itemQty
121
+ * @return bool
122
+ */
123
+ private function isValidRefundQty ($ isQtyDecimal , float $ itemQty ): bool
124
+ {
125
+ if (!$ isQtyDecimal && (floor ($ itemQty ) !== $ itemQty )) {
126
+ return true ;
127
+ }
128
+ return false ;
129
+ }
130
+
108
131
/**
109
132
* We can have problem with float in php (on some server $a=762.73;$b=762.73; $a-$b!=0)
110
133
* for this we have additional diapason for 0
Original file line number Diff line number Diff line change @@ -806,3 +806,4 @@ If set YES Email field will be required during Admin order creation for new Cust
806
806
"The coupon code has been removed.","The coupon code has been removed."
807
807
"This creditmemo no longer exists.","This creditmemo no longer exists."
808
808
"Add to address book","Add to address book"
809
+ "You cannot use decimal quantity to refund item","You cannot use decimal quantity to refund item"
You can’t perform that action at this time.
0 commit comments