mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-09 23:24:06 -08:00
Calculate the proper amount of assigned components
This commit is contained in:
parent
b52c00d49b
commit
ea8f12579d
|
@ -623,7 +623,7 @@ class Helper
|
|||
{
|
||||
$consumables = Consumable::withCount('consumableAssignments as consumable_assignments_count')->whereNotNull('min_amt')->get();
|
||||
$accessories = Accessory::withCount('users as users_count')->whereNotNull('min_amt')->get();
|
||||
$components = Component::withCount('assets as assets_count')->whereNotNull('min_amt')->get();
|
||||
$components = Component::whereNotNull('min_amt')->get();
|
||||
|
||||
$avail_consumables = 0;
|
||||
$items_array = [];
|
||||
|
@ -668,7 +668,9 @@ class Helper
|
|||
}
|
||||
|
||||
foreach ($components as $component) {
|
||||
$avail = $component->qty - $component->assets_count;
|
||||
$assets_count = \DB::table('components_assets')->where('component_id', $component->id)->sum('assigned_qty');
|
||||
|
||||
$avail = $component->qty - $assets_count;
|
||||
if ($avail < ($component->min_amt) + \App\Models\Setting::getSettings()->alert_threshold) {
|
||||
if ($component->qty > 0) {
|
||||
$percent = number_format((($avail / $component->qty) * 100), 0);
|
||||
|
|
Loading…
Reference in a new issue