// The cost has to be adjusted.
// Transaction rates are stored either as price or standard_cost depending on types
$types = array(ST_SUPPCREDIT, ST_SUPPRECEIVE);
- if (in_array($type,$types))
- $trans_rate = $row["price"];
+ if (in_array($type, $types))
+ $unit_cost = $row["price"];
else
- $trans_rate = $row["standard_cost"];
+ $unit_cost = $row["standard_cost"];
- update_average_material_cost(0, $row["stock_id"],
- $trans_rate, -$row["qty"], sql2date($row["tran_date"]));
+ update_average_material_cost($row["person_id"], $row["stock_id"],
+ $unit_cost, -$row["qty"], sql2date($row["tran_date"]));
}
}
$qoh = 0;
}
if ($qoh + $qty > 0)
- $material_cost
-= ($qoh * $material_cost + $qty * $price_in_home_currency) / ($qoh + $qty);
- }
-
+ $material_cost = ($qoh * $material_cost + $qty * $price_in_home_currency) / ($qoh + $qty);
+ }
+
if ($cost_adjust) // new 2010-02-10 //Chaitanya : Material_cost replaced with price
adjust_deliveries($stock_id, $price_in_home_currency_, $date);
$sql = "UPDATE ".TB_PREF."stock_master SET material_cost=".db_escape($material_cost)."
WHERE stock_id=".db_escape($stock_id);
+
db_query($sql,"The cost details for the inventory item could not be updated");
return $material_cost;
}