From da520fc7ac8057b9554eaacfbdad2aee9d5b62d6 Mon Sep 17 00:00:00 2001
From: Prasad <prasad@vtiger.com>
Date: Mon, 22 Apr 2024 11:20:06 +0530
Subject: [PATCH] Fixes Shipping and Handling charges invalid state

---
 modules/Migration/schema/660_to_700.php | 2 +-
 modules/Migration/schema/811_to_812.php | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/modules/Migration/schema/660_to_700.php b/modules/Migration/schema/660_to_700.php
index 992991dd0..58d2c4031 100644
--- a/modules/Migration/schema/660_to_700.php
+++ b/modules/Migration/schema/660_to_700.php
@@ -1551,7 +1551,7 @@ if(defined('VTIGER_UPGRADE')) {
 			$taxIdsList[] = $rowData['taxid'];
 		}
 
-		$db->pquery('INSERT INTO vtiger_inventorycharges VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?)', array(1, 'Shipping & Handling', 'Flat', 'Fixed', null, '[]', 1, ZEND_JSON::encode($taxIdsList), 0));
+		$db->pquery('INSERT INTO vtiger_inventorycharges VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?)', array(1, 'Shipping & Handling', 'Flat', 'Fixed', 0, '[]', 1, ZEND_JSON::encode($taxIdsList), 0));
 	}
 
 	if (!Vtiger_Utils::checkTable('vtiger_inventorychargesrel')) {
diff --git a/modules/Migration/schema/811_to_812.php b/modules/Migration/schema/811_to_812.php
index a0c51c0ef..4eec01212 100644
--- a/modules/Migration/schema/811_to_812.php
+++ b/modules/Migration/schema/811_to_812.php
@@ -28,4 +28,8 @@ if (defined('VTIGER_UPGRADE')) {
     // Disabling the mass edit for the inventory line item discount fields.
     $db->pquery("UPDATE vtiger_field set masseditable = 0 where columnname in ('discount_percent','discount_amount') 
     and tablename in ('vtiger_quotes','vtiger_purchaseorder','vtiger_salesorder','vtiger_invoice')", array());
+
+    // Set value to 0 to avoid NaN troubles.
+    $db->pquery("UPDATE vtiger_inventorycharges SET value = 0 WHERE  name = 'Shipping & Handling' and value IS NULL",array());
+
 }
-- 
GitLab