Skip to content

Commit 8e9b967

Browse files
authored
Rename wrongly named variable
While the variable was named totalRefund it contains the amount of money that can still be refunded. This confused me while debugging an unrelated issue for a customer. I felt renaming the attribute might prevent future developers from doing the same.
1 parent fa3d6ec commit 8e9b967

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -708,25 +708,25 @@ public function canCreditmemo()
708708
* for this we have additional diapason for 0
709709
* TotalPaid - contains amount, that were not rounded.
710710
*/
711-
$totalRefunded = $this->priceCurrency->round($this->getTotalPaid()) - $this->getTotalRefunded();
711+
$totalRefundable = $this->priceCurrency->round($this->getTotalPaid()) - $this->getTotalRefunded();
712712
if (abs((float) $this->getGrandTotal()) < .0001) {
713-
return $this->canCreditmemoForZeroTotal($totalRefunded);
713+
return $this->canCreditmemoForZeroTotal($totalRefundable);
714714
}
715715

716-
return $this->canCreditmemoForZeroTotalRefunded($totalRefunded);
716+
return $this->canCreditmemoForZeroTotalRefunded($totalRefundable);
717717
}
718718

719719
/**
720720
* Retrieve credit memo for zero total refunded availability.
721721
*
722-
* @param float $totalRefunded
722+
* @param float $totalRefundable
723723
* @return bool
724724
*/
725-
private function canCreditmemoForZeroTotalRefunded($totalRefunded)
725+
private function canCreditmemoForZeroTotalRefunded($totalRefundable)
726726
{
727-
$isRefundZero = abs((float) $totalRefunded) < .0001;
727+
$isRefundZero = abs((float) $totalRefundable) < .0001;
728728
// Case when Adjustment Fee (adjustment_negative) has been used for first creditmemo
729-
$hasAdjustmentFee = abs($totalRefunded - $this->getAdjustmentNegative()) < .0001;
729+
$hasAdjustmentFee = abs($totalRefundable - $this->getAdjustmentNegative()) < .0001;
730730
$hasActionFlag = $this->getActionFlag(self::ACTION_FLAG_EDIT) === false;
731731
if ($isRefundZero || $hasAdjustmentFee || $hasActionFlag) {
732732
return false;
@@ -738,10 +738,10 @@ private function canCreditmemoForZeroTotalRefunded($totalRefunded)
738738
/**
739739
* Retrieve credit memo for zero total availability.
740740
*
741-
* @param float $totalRefunded
741+
* @param float $totalRefundable
742742
* @return bool
743743
*/
744-
private function canCreditmemoForZeroTotal($totalRefunded)
744+
private function canCreditmemoForZeroTotal($totalRefundable)
745745
{
746746
$totalPaid = $this->getTotalPaid();
747747
//check if total paid is less than grandtotal
@@ -754,7 +754,7 @@ private function canCreditmemoForZeroTotal($totalRefunded)
754754
$paidAmtIsRefunded = $this->getTotalRefunded() == $totalPaid && $creditmemos;
755755
if (($hasDueAmount || $paidAmtIsRefunded) ||
756756
(!$checkAmtTotalPaid &&
757-
abs($totalRefunded - $this->getAdjustmentNegative()) < .0001)) {
757+
abs($totalRefundable - $this->getAdjustmentNegative()) < .0001)) {
758758
return false;
759759
}
760760
return true;

0 commit comments

Comments
 (0)