From 0bd7170c9d32dd3113059e8bf4daa5cb0a96cc14 Mon Sep 17 00:00:00 2001 From: Joe Hunt Date: Thu, 2 Feb 2012 08:24:51 +0100 Subject: [PATCH] Fixed small bugs in function void_stock_move in file /includes/db/inventory_db.inc. --- includes/db/inventory_db.inc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/includes/db/inventory_db.inc b/includes/db/inventory_db.inc index 093ea6f..068c164 100644 --- a/includes/db/inventory_db.inc +++ b/includes/db/inventory_db.inc @@ -381,8 +381,12 @@ function get_stock_moves($type, $type_no, $visible=false) function void_stock_move($type, $type_no) { - - $sql = "SELECT * from ".TB_PREF."stock_moves WHERE type=".db_escape($type)." AND trans_no=".db_escape($type_no); + + $sql = "SELECT stock_id, standard_cost, loc_code, tran_date, reference, person_id, visible, discount_percent, price, + sum(qty) qty FROM ".TB_PREF."stock_moves WHERE type=".db_escape($type)." AND trans_no=".db_escape($type_no)." + GROUP BY stock_id, standard_cost, loc_code, tran_date, reference, person_id, visible, discount_percent, price HAVING sum(qty) <> 0"; + + $result = db_query($sql, "Could not void stock moves"); while ($row = db_fetch($result)) { @@ -390,7 +394,7 @@ function void_stock_move($type, $type_no) if (is_inventory_item($row["stock_id"])) { // The cost has to be adjusted. - // Transaction rates are stored either as price or standard_cost depending on types + // Transaction rates are stored either as price or standard_cost depending on types $types = array(ST_SUPPCREDIT, ST_SUPPRECEIVE); if (in_array($type,$types)) $trans_rate = $row["price"]; @@ -406,7 +410,7 @@ function void_stock_move($type, $type_no) sql2date($row["tran_date"]), $row["reference"], -$row["qty"] , $row["standard_cost"], $row["person_id"], $row["visible"], $row["price"], $row["discount_percent"]); - } + } } //-------------------------------------------------------------------------------------------------- -- 2.30.2