Change db query for an existing method

This commit is contained in:
Ivan Nieto Vivanco 2022-08-04 09:20:20 -05:00
parent ea8f12579d
commit c055c91739

View file

@ -668,9 +668,7 @@ class Helper
}
foreach ($components as $component) {
$assets_count = \DB::table('components_assets')->where('component_id', $component->id)->sum('assigned_qty');
$avail = $component->qty - $assets_count;
$avail = $component->numRemaining();
if ($avail < ($component->min_amt) + \App\Models\Setting::getSettings()->alert_threshold) {
if ($component->qty > 0) {
$percent = number_format((($avail / $component->qty) * 100), 0);