From c8b1b32b7122d75333f0250147b445ccf209c37f Mon Sep 17 00:00:00 2001 From: Jonathan Miller Date: Sat, 20 Jun 2026 23:38:25 -0500 Subject: [PATCH] fix: warranty claim operator precedence bug + WO validation --- .../src/Helper/WarrantyHelper.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/source/packages/plg_system_mokosuitefield/src/Helper/WarrantyHelper.php b/source/packages/plg_system_mokosuitefield/src/Helper/WarrantyHelper.php index c1f3eb0..093fef5 100644 --- a/source/packages/plg_system_mokosuitefield/src/Helper/WarrantyHelper.php +++ b/source/packages/plg_system_mokosuitefield/src/Helper/WarrantyHelper.php @@ -54,9 +54,16 @@ class WarrantyHelper { $warranty = self::checkWarranty($equipmentId); - if (!$warranty->found ?? true) return (object) ['success' => false, 'error' => 'Equipment not found']; + if (empty($warranty->id)) return (object) ['success' => false, 'error' => 'Equipment not found']; if (!$warranty->under_warranty) return (object) ['success' => false, 'error' => 'Warranty expired']; + // Verify work order exists and is linked to this equipment + $db->setQuery($db->getQuery(true)->select('id')->from('#__mokosuitefield_work_orders') + ->where('id = ' . (int) $woId)); + if (!(int) $db->loadResult()) { + return (object) ['success' => false, 'error' => 'Invalid work order']; + } + $db = Factory::getContainer()->get(DatabaseInterface::class); $now = Factory::getDate()->toSql();