From 51a2c126f6cc72285b2957a1e17149c6678d69b6 Mon Sep 17 00:00:00 2001
From: Prasad <prasad@vtiger.com>
Date: Fri, 14 Jun 2024 19:15:20 +0530
Subject: [PATCH] Fix for division-by-zero php 8.x when computing price by
 conversion rate

---
 include/utils/InventoryUtils.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/utils/InventoryUtils.php b/include/utils/InventoryUtils.php
index 284914d25..0329f8fca 100644
--- a/include/utils/InventoryUtils.php
+++ b/include/utils/InventoryUtils.php
@@ -1200,7 +1200,7 @@ function getBaseConversionRateForProduct($productid, $mode='edit', $module='Prod
 	$res = $adb->pquery($sql, $params);
 	$conv_rate = $adb->query_result($res, 0, 'conversion_rate');
 
-	return 1 / $conv_rate;
+	return $conv_rate ? (1 / $conv_rate) : 1;
 }
 
 /**	Function used to get the prices for the given list of products based in the specified currency
-- 
GitLab