3 //-------------------------------------------------------------------------------------------------------------
5 function stock_cost_update($stock_id, $material_cost, $labour_cost, $overhead_cost,
8 $mb_flag = get_mb_flag($stock_id);
10 if (is_service($mb_flag))
12 display_db_error("Cannot do cost update for Service item : $stock_id", "");
19 $sql = "UPDATE ".TB_PREF."stock_master SET material_cost=$material_cost,
20 labour_cost=$labour_cost,
21 overhead_cost=$overhead_cost,
23 WHERE stock_id='$stock_id'";
24 db_query($sql,"The cost details for the inventory item could not be updated");
26 $qoh = get_qoh_on_date($_POST['stock_id']);
31 $update_no = get_next_trans_no(systypes::cost_update());
33 if (!is_date_in_fiscalyear($date_))
34 $date_ = end_fiscalyear();
36 $stock_gl_code = get_stock_gl_code($stock_id);
38 $new_cost = $material_cost + $labour_cost + $overhead_cost;
40 $value_of_change = $qoh * ($new_cost - $last_cost);
42 $memo_ = "Cost was " . $last_cost . " changed to " . $new_cost . " x quantity on hand of $qoh";
43 add_gl_trans_std_cost(systypes::cost_update(), $update_no, $date_, $stock_gl_code["adjustment_account"],
44 $stock_gl_code["dimension_id"], $stock_gl_code["dimension2_id"], $memo_, (-$value_of_change));
46 add_gl_trans_std_cost(systypes::cost_update(), $update_no, $date_, $stock_gl_code["inventory_account"], 0, 0, $memo_,
55 //-------------------------------------------------------------------------------------------------------------