+ //------------------- update average material cost ------------------------------------------ Joe Hunt Mar-03-2008
+ $currency = get_supplier_currency($po->supplier_id);
+ if ($currency != null)
+ $price_in_home_currency = to_home_currency($order_line->price, $currency, $date_);
+ else
+ $price_in_home_currency = $order_line->price;
+ $sql = "SELECT material_cost FROM ".TB_PREF."stock_master WHERE stock_id='$order_line->stock_id'";
+ $result = db_query($sql);
+ $myrow = db_fetch($result);
+ $material_cost = $myrow['material_cost'];
+ $qoh = get_qoh_on_date($order_line->stock_id, null, $date_);
+ $material_cost = ($qoh * $material_cost + $order_line->receive_qty * $price_in_home_currency) /
+ ($qoh + $order_line->receive_qty);
+ $sql = "UPDATE ".TB_PREF."stock_master SET material_cost=$material_cost
+ WHERE stock_id='$order_line->stock_id'";
+ db_query($sql,"The cost details for the inventory item could not be updated");
+ //----------------------------------------------------------------------------------------------------------------
+