projects
/
fa-stable.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Additional access control related ui helpers added: check_edit_access, access_post...
[fa-stable.git]
/
includes
/
ui
/
items_cart.inc
diff --git
a/includes/ui/items_cart.inc
b/includes/ui/items_cart.inc
index 25101807d61c6b26b04448e5ce2a7b3b1e871edc..c836f487fa1a869342ddd7393d6a65d5e9777471 100644
(file)
--- a/
includes/ui/items_cart.inc
+++ b/
includes/ui/items_cart.inc
@@
-81,15
+81,32
@@
class items_cart
return count($this->line_items);
}
return count($this->line_items);
}
+ /*
+ Checks cart quantities on document_date.
+ Returns array of stock_ids which stock quantities would go negative on some day.
+ */
function check_qoh($location, $date_, $reverse=false)
{
function check_qoh($location, $date_, $reverse=false)
{
+ $low_stock = array();
+
+ // collect quantities by stock_id
+ $qtys = array();
foreach ($this->line_items as $line_no => $line_item)
{
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;
+ $qty = $reverse ? -$line_item->quantity : $line_item->quantity;
+
+ $qtys[$line_item->stock_id]['qty'] = $qty + @$qtys[$line_item->stock_id]['qty'];
+ $qtys[$line_item->stock_id]['line'] = $line_no;
}
}
- return -1;
+
+ foreach($qtys as $stock_id => $sum)
+ {
+ $fail = check_negative_stock($stock_id, $sum['qty'], $location, $date_);
+ if ($fail)
+ $low_stock[] = $stock_id;
+ }
+
+ return $low_stock;
}
// ----------- GL item functions
}
// ----------- GL item functions
@@
-240,10
+257,14
@@
class line_item
$this->price = 0;
}
$this->price = 0;
}
+ /*
+ This method is generally obsolete and subject to removal in FA 2.4 (preserved for now to support 2.3 extensions).
+ Use items_cart::check_qoh instead.
+ */
function check_qoh($location, $date_, $reverse)
{
global $SysPrefs;
function check_qoh($location, $date_, $reverse)
{
global $SysPrefs;
-
+
if (!$SysPrefs->allow_negative_stock())
{
if (has_stock_holding($this->mb_flag))
if (!$SysPrefs->allow_negative_stock())
{
if (has_stock_holding($this->mb_flag))
@@
-255,11
+276,9
@@
class line_item
if ($quantity >= 0)
return null;
if ($quantity >= 0)
return null;
- $qoh = get_qoh_on_date($this->stock_id, $location, $date_);
- if ($quantity + $qoh < 0)
- {
- return $this;
- }
+ $fail = check_negative_stock($this->stock_id, $quantity, $location, $date_);
+ if ($fail)
+ return $this;
}
}
}
}
@@
-309,4
+328,3
@@
class gl_item
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
-?>