while ($row = db_fetch($result))
{
add_stock_move($type, $row["stock_id"], $type_no, $row["loc_code"],
- sql2date($row["tran_date"]), $row["reference"], -$row["qty"], $row["standard_cost"], $row["person_id"], $row["visible"],
- $row["price"], $row["discount_percent"]);
+ sql2date($row["tran_date"]), $row["reference"], -$row["qty"], $row["standard_cost"], $row["person_id"], $row["visible"],
+ $row["price"], $row["discount_percent"]);
// If there is cost difference, then cost has to be adjusted.
// IMP : Adjusting cost is suitable instead of normal averaging as it will not work properly for manufactured items. Reason being Avg cost is suitable only for purchased items
+
$curr_std_cost = get_standard_cost($row["stock_id"]);
- if ($curr_std_cost != $row["standard_cost"])
+
+ //Chaitanya : Transaction rates are stored either as price or standard_cost depending
+ //on types
+ $types = array(ST_SUPPCREDIT);
+ if (in_array($type,$types))
+ $trans_rate = $row["price"];
+ else
+ $trans_rate = $row["standard_cost"];
+
+ if ($curr_std_cost != $trans_rate)
{
- $cost_diff = $row["standard_cost"] - $curr_std_cost;
+ $cost_diff = $trans_rate - $curr_std_cost;
update_average_material_cost(0, $row["stock_id"],
$cost_diff, -$row["qty"], sql2date($row["tran_date"]), true);
}
+
}
}