X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=includes%2Fdb%2Finventory_db.inc;h=46a16b41706de5cfecbe43c15f52f1f6af9c733a;hb=171074993d8f6768cde0626697abd6b4eab732a6;hp=562c8d1b1d866c970dc552026b5ec0cca685e4da;hpb=c55119ade6f4c6bd4acdfa55c46870187f408978;p=fa-stable.git diff --git a/includes/db/inventory_db.inc b/includes/db/inventory_db.inc index 562c8d1b..46a16b41 100644 --- a/includes/db/inventory_db.inc +++ b/includes/db/inventory_db.inc @@ -1,6 +1,6 @@ 0) + { + $sql = "SELECT SUM(qty) FROM ".TB_PREF."stock_moves + WHERE stock_id='$stock_id' + AND type=$exclude + AND tran_date = '$date'"; + + $result = db_query($sql, "QOH calulcation failed"); + $myrow2 = db_fetch_row($result); + if ($myrow2 !== false) + $myrow[0] -= $myrow2[0]; + } return $myrow[0]; } @@ -78,7 +90,7 @@ Function get_stock_gl_code($stock_id) // $price - in $person_id's currency function add_stock_move($type, $stock_id, $trans_no, $location, - $date_, $reference, $quantity, $std_cost, $person_id=null, $show_or_hide=1, + $date_, $reference, $quantity, $std_cost, $person_id=0, $show_or_hide=1, $price=0, $discount_percent=0, $error_msg="") { // do not add a stock move if it's a non-inventory item @@ -101,6 +113,15 @@ function add_stock_move($type, $stock_id, $trans_no, $location, return db_insert_id(); } +function update_stock_move_pid($type, $stock_id, $from, $to, $pid, $cost) +{ + $from = date2sql($from); + $to = date2sql($to); + $sql = "UPDATE ".TB_PREF."stock_moves SET standard_cost=$cost WHERE type=$type + AND stock_id='$stock_id' AND tran_date>='$from' AND tran_date<='$to' AND person_id = $pid"; + db_query($sql, "The stock movement standard_cost cannot be updated"); +} + //-------------------------------------------------------------------------------------------------- function get_stock_moves($type, $type_no, $visible=false)