- foreach ($this->line_items as $line_no => $line_item)
- {
- $item_ret = $line_item->check_qoh($location, $date_, $reverse);
- if ($item_ret != null)
- return $line_no;
+ global $SysPrefs;
+
+ $low_stock = array();
+
+ if (!$SysPrefs->allow_negative_stock() || is_fixed_asset($line_item->mb_flag))
+ {
+ foreach ($this->line_items as $line_no => $line_item)
+ if (has_stock_holding($line_item->mb_flag) || is_fixed_asset($line_item->mb_flag))
+ {
+ $quantity = $line_item->quantity;
+ if ($reverse)
+ $quantity = -$line_item->quantity;
+
+ if ($quantity >= 0)
+ continue;
+
+ if (check_negative_stock($line_item->stock_id, $quantity, $location, $date_))
+ $low_stock[] = $line_item->stock_id;
+ }