From c68d9892b5c5f97f76c3b33bad4cf4d840a5618c Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Wed, 3 Dec 2025 13:20:01 -0800 Subject: [PATCH] fix threshold bug, include minimum to available --- app/Helpers/Helper.php | 10 +++++----- app/Notifications/InventoryAlert.php | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/Helpers/Helper.php b/app/Helpers/Helper.php index 963bc8ea77..2496d1e281 100644 --- a/app/Helpers/Helper.php +++ b/app/Helpers/Helper.php @@ -784,7 +784,7 @@ class Helper foreach ($consumables as $consumable) { $avail = $consumable->numRemaining(); - if ($avail < ($consumable->min_amt) + $alert_threshold) { + if ($avail <= ($consumable->min_amt) - $alert_threshold) { if ($consumable->qty > 0) { $percent = number_format((($avail / $consumable->qty) * 100), 0); } else { @@ -803,7 +803,7 @@ class Helper foreach ($accessories as $accessory) { $avail = $accessory->qty - $accessory->checkouts_count; - if ($avail < ($accessory->min_amt) + $alert_threshold) { + if ($avail <= ($accessory->min_amt) - $alert_threshold) { if ($accessory->qty > 0) { $percent = number_format((($avail / $accessory->qty) * 100), 0); } else { @@ -822,7 +822,7 @@ class Helper foreach ($components as $component) { $avail = $component->numRemaining(); - if ($avail < ($component->min_amt) + $alert_threshold) { + if ($avail <= ($component->min_amt) + $alert_threshold) { if ($component->qty > 0) { $percent = number_format((($avail / $component->qty) * 100), 0); } else { @@ -845,7 +845,7 @@ class Helper $total_owned = $asset->where('model_id', '=', $asset_model->id)->count(); $avail = $asset->where('model_id', '=', $asset_model->id)->whereNull('assigned_to')->count(); - if ($avail < ($asset_model->min_amt) + $alert_threshold) { + if ($avail <= ($asset_model->min_amt) + $alert_threshold) { if ($avail > 0) { $percent = number_format((($avail / $total_owned) * 100), 0); } else { @@ -863,7 +863,7 @@ class Helper foreach ($licenses as $license){ $avail = $license->remaincount(); - if ($avail < ($license->min_amt) + $alert_threshold) { + if ($avail <= ($license->min_amt) + $alert_threshold) { if ($avail > 0) { $percent = number_format((($avail / $license->min_amt) * 100), 0); } else { diff --git a/app/Notifications/InventoryAlert.php b/app/Notifications/InventoryAlert.php index bd6f10b03a..17723ad145 100644 --- a/app/Notifications/InventoryAlert.php +++ b/app/Notifications/InventoryAlert.php @@ -25,7 +25,7 @@ class InventoryAlert extends Notification public function __construct($params, $threshold) { $this->items = $params; - $this->threshold = $threshold; + $this->threshold = $threshold ?? 0; } /**