X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=purchasing%2Fincludes%2Fdb%2Fgrn_db.inc;h=756c972fecb5d3f59b6daa7e378999430b263e56;hb=171074993d8f6768cde0626697abd6b4eab732a6;hp=0118fa376629923bcf62476de20e0e732a4a42b4;hpb=e28f3fe01f168d761393ce2f10409284eef2adb4;p=fa-stable.git diff --git a/purchasing/includes/db/grn_db.inc b/purchasing/includes/db/grn_db.inc index 0118fa37..756c972f 100644 --- a/purchasing/includes/db/grn_db.inc +++ b/purchasing/includes/db/grn_db.inc @@ -2,7 +2,7 @@ //------------------- update average material cost ------------------------------------------ Joe Hunt Mar-03-2008 -function update_average_material_cost($supplier, $stock_id, $price, $qty, $date, $adj_only) +function update_average_material_cost($supplier, $stock_id, $price, $qty, $date, $adj_only=false) { $currency = get_supplier_currency($supplier); if ($currency != null) @@ -13,7 +13,12 @@ function update_average_material_cost($supplier, $stock_id, $price, $qty, $date, $result = db_query($sql); $myrow = db_fetch($result); $material_cost = $myrow['material_cost']; - $qoh = get_qoh_on_date($stock_id, null, $date); + if ($adj_only) + $exclude = 13; + else + $exclude = 0; + $qoh = get_qoh_on_date($stock_id, null, $date, $exclude); + if ($qoh + $qty <= 0) $material_cost = 0; else @@ -69,7 +74,6 @@ function add_grn(&$po, $date_, $reference, $location) $order_line->standard_cost, $order_line->receive_qty, $order_line->price); /* Update location stock records - NB a po cannot be entered for a service/kit parts */ - add_stock_move(25, $order_line->stock_id, $grn, $location, $date_, "", $order_line->receive_qty, $order_line->standard_cost, $po->supplier_id, 1, $order_line->price);