X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;ds=sidebyside;f=includes%2Fui%2Fitems_cart.inc;h=f517edd973ce3241dd10107d1c66442f770d9047;hb=9a1b3abd5371ad7f6315db1d56f8356587444314;hp=e2a2ca917b9a2fac75adc4559faa100053dc85d0;hpb=92101d528a49ac3dda0a0f06960313b9a2794fd6;p=fa-stable.git diff --git a/includes/ui/items_cart.inc b/includes/ui/items_cart.inc index e2a2ca91..f517edd9 100644 --- a/includes/ui/items_cart.inc +++ b/includes/ui/items_cart.inc @@ -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; - } } //---------------------------------------------------------------------------------------