Skip to content

Commit bc4032c

Browse files
authored
Merge pull request #11617 from inietov/fixes/components_wrong_remaining_inventory
Fixed wrong calculation of assigned components
2 parents 5f93d7b + c055c91 commit bc4032c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

app/Helpers/Helper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ public static function checkLowInventory()
623623
{
624624
$consumables = Consumable::withCount('consumableAssignments as consumable_assignments_count')->whereNotNull('min_amt')->get();
625625
$accessories = Accessory::withCount('users as users_count')->whereNotNull('min_amt')->get();
626-
$components = Component::withCount('assets as assets_count')->whereNotNull('min_amt')->get();
626+
$components = Component::whereNotNull('min_amt')->get();
627627

628628
$avail_consumables = 0;
629629
$items_array = [];
@@ -668,7 +668,7 @@ public static function checkLowInventory()
668668
}
669669

670670
foreach ($components as $component) {
671-
$avail = $component->qty - $component->assets_count;
671+
$avail = $component->numRemaining();
672672
if ($avail < ($component->min_amt) + \App\Models\Setting::getSettings()->alert_threshold) {
673673
if ($component->qty > 0) {
674674
$percent = number_format((($avail / $component->qty) * 100), 0);

0 commit comments

Comments
 (0)