-
-//--------------------------------------------------------------------------------------
-
-function add_material_cost($stock_id, $qty, $date_)
-{
- $m_cost = 0;
- $result = get_bom($stock_id);
- while ($bom_item = db_fetch($result))
- {
- $sql = "SELECT material_cost FROM ".TB_PREF."stock_master WHERE stock_id = '".$bom_item['component']."'";
- $res = db_query($sql);
- $myrow = db_fetch($res);
- $m_cost += ($bom_item['quantity'] * $myrow['material_cost']);
- }
- $sql = "SELECT material_cost FROM ".TB_PREF."stock_master WHERE stock_id = '$stock_id'";
- $result = db_query($sql);
- $myrow = db_fetch($result);
- $material_cost = $myrow['material_cost'];
- $qoh = get_qoh_on_date($stock_id, null, $date_);
- if ($qoh + $qty <= 0)
- $material_cost = 0;
- else
- $material_cost = ($qoh * $material_cost + $qty * $m_cost) / ($qoh + $qty);
- $sql = "UPDATE ".TB_PREF."stock_master SET material_cost=$material_cost
- WHERE stock_id='$stock_id'";
- db_query($sql,"The cost details for the inventory item could not be updated");
-}
-
+/**********************************************************************
+ Copyright (C) FrontAccounting, LLC.
+ Released under the terms of the GNU General Public License, GPL,
+ as published by the Free Software Foundation, either version 3
+ of the License, or (at your option) any later version.
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
+***********************************************************************/
+/*
+ Common entry procedure for all work order types
+*/