[0003246] Fixed wrong url generated by menu_link helper in final transaction entry...
[fa-stable.git] / includes / ui / items_cart.inc
index e2a2ca917b9a2fac75adc4559faa100053dc85d0..f517edd973ce3241dd10107d1c66442f770d9047 100644 (file)
@@ -95,13 +95,27 @@ class items_cart
 
        function check_qoh($location, $date_, $reverse=false)
        {
-               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())
+       {
+                       foreach ($this->line_items as $line_no => $line_item)
+                               if (has_stock_holding($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;
+                       }
                }
-               return -1;
+               return $low_stock;
        }
 
        // ----------- GL item functions
@@ -472,32 +486,6 @@ class line_item
                //$this->price = $price;
                $this->price = 0;
        }
-
-       function check_qoh($location, $date_, $reverse)
-       {
-               global $SysPrefs;
-               
-       if (!$SysPrefs->allow_negative_stock())
-       {
-                       if (has_stock_holding($this->mb_flag))
-                       {
-                               $quantity = $this->quantity;
-                               if ($reverse)
-                                       $quantity = -$this->quantity;
-
-                               if ($quantity >= 0)
-                                       return null;
-
-                               $qoh = get_qoh_on_date($this->stock_id, $location, $date_);
-                       if ($quantity + $qoh < 0)
-                       {
-                               return $this;
-                       }
-               }
-       }
-
-       return null;
-       }
 }
 
 //---------------------------------------------------------------------------------------