Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions app/Helpers/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,7 @@ public static function checkLowInventory()

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 {
Expand All @@ -803,7 +803,7 @@ public static function checkLowInventory()

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 {
Expand All @@ -822,7 +822,7 @@ public static function checkLowInventory()

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 {
Expand All @@ -845,7 +845,7 @@ public static function checkLowInventory()
$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 {
Expand All @@ -863,7 +863,7 @@ public static function checkLowInventory()

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 {
Expand Down
2 changes: 1 addition & 1 deletion app/Notifications/InventoryAlert.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class InventoryAlert extends Notification
public function __construct($params, $threshold)
{
$this->items = $params;
$this->threshold = $threshold;
$this->threshold = $threshold ?? 0;
}

/**
Expand Down
Loading