A free open source IT asset/license management system
fix threshold bug, include minimum to available
Godfrey Mc68d9892b5c5
diff --git a/app/Helpers/Helper.php b/app/Helpers/Helper.phpindex 963bc8ea77..2496d1e281 100644--- a/app/Helpers/Helper.php+++ b/app/Helpers/Helper.php@@ -784,7 +784,7 @@ class Helperforeach ($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 Helperforeach ($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 Helperforeach ($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 Helperforeach ($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.phpindex bd6f10b03a..17723ad145 100644--- a/app/Notifications/InventoryAlert.php+++ b/app/Notifications/InventoryAlert.php@@ -25,7 +25,7 @@ class InventoryAlert extends Notificationpublic function __construct($params, $threshold){$this->items = $params;- $this->threshold = $threshold;+ $this->threshold = $threshold ?? 0;}/**