From 2992740e56150d5e5fb6bf8232a7ad46e7ca656c Mon Sep 17 00:00:00 2001 From: Genius-Dev Date: Tue, 25 May 2021 09:44:26 +0200 Subject: [PATCH] Division by zero fix --- Model/Total/Creditmemo.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Model/Total/Creditmemo.php b/Model/Total/Creditmemo.php index 1899e88..7eaf539 100644 --- a/Model/Total/Creditmemo.php +++ b/Model/Total/Creditmemo.php @@ -90,9 +90,9 @@ private function setCustomRefund(MagentoCreditmemo $creditmemo) $rate = $creditmemo->getBaseToOrderRate(); $customFee = $this->helper->roundPrice($baseCustomFee * $rate); - $taxRate = $creditmemo->getBaseCodFeeInclTax() / $creditmemo->getBaseCodFee(); + $taxRate = $creditmemo->getBaseCodFee() != 0 ? $creditmemo->getBaseCodFeeInclTax() / $creditmemo->getBaseCodFee() : 0; - if ($this->config->codFeeIncludesTax()) { + if ($taxRate > 0 && $this->config->codFeeIncludesTax()) { $baseCodFeeInclTax = $baseCustomFee; $codFeeInclTax = $customFee; @@ -124,6 +124,11 @@ private function setCustomRefund(MagentoCreditmemo $creditmemo) private function isPartialShippingRefunded(MagentoCreditmemo $creditmemo) { + if($creditmemo->getOrder()->getShippingAmount()<=0) + { + return false; + } + $part = $creditmemo->getShippingAmount() / $creditmemo->getOrder()->getShippingAmount(); return $part < 1 && $creditmemo->getOrder()->getShippingTaxAmount() > 0;