Merged latest changes from stable branch.
[fa-stable.git] / includes / db / inventory_db.inc
index e0ea2ef7646f00d33338e2ab29246d0561b5dcf0..5613ecb8d8eba24b13f1b3839a4914da9323056f 100644 (file)
@@ -381,9 +381,7 @@ function get_stock_moves($type, $type_no, $visible=false)
 
 function void_stock_move($type, $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";
+    $sql = "SELECT * from ".TB_PREF."stock_moves WHERE type=".db_escape($type)." AND trans_no=".db_escape($type_no);
 
     $result = db_query($sql, "Could not void stock moves");
     while ($row = db_fetch($result))
@@ -403,12 +401,10 @@ function void_stock_move($type, $type_no)
                                $trans_rate, -$row["qty"], sql2date($row["tran_date"]));
                }
 
-               //Post stock move for service items also
-        add_stock_move($type, $row["stock_id"], $type_no, $row["loc_code"],
-               sql2date($row["tran_date"]), $row["reference"], -$row["qty"]
-                       , $row["standard_cost"], $row["person_id"], $row["visible"],
-               $row["price"], $row["discount_percent"]);
     }
+       $sql = "DELETE FROM ".TB_PREF."stock_moves WHERE type=".db_escape($type)
+               ."      AND trans_no=".db_escape($type_no);
+       db_query($sql, "The stock movement cannot be delated");
 }
 
 //--------------------------------------------------------------------------------------------------