-function get_fixed_asset_purchase($stock_id) {
-
- $sql = "SELECT *
- FROM ".TB_PREF."stock_master m, "
- .TB_PREF."supp_invoice_items i, "
- .TB_PREF."supp_trans t
- WHERE m.stock_id=".db_escape($stock_id)."
- AND i.supp_trans_no=t.trans_no
- AND m.stock_id=i.stock_id";
-
- $result = db_query($sql, "cannot retrieve fixed asset move");
-
- if (db_num_rows($result) == 0)
- return false;
-
- $row = db_fetch_assoc($result);
- return $row;
-}
-
-//--------------------------------------------------------------------------------------------------
-
-function get_initial_price($stock_id) {
- $row = get_fixed_asset_move($stock_id, ST_SUPPRECEIVE);
- return $row['price'];
+function get_fixed_asset_purchase($stock_id)
+{
+ $sql = "SELECT *
+ FROM ".TB_PREF."stock_master m, "
+ .TB_PREF."supp_invoice_items i, "
+ .TB_PREF."supp_trans t
+ WHERE m.stock_id=".db_escape($stock_id)."
+ AND i.supp_trans_no=t.trans_no
+ AND m.stock_id=i.stock_id
+ ORDER BY t.tran_date DESC
+ LIMIT 1";
+
+ $result = db_query($sql, "cannot retrieve fixed asset move");
+
+ if (db_num_rows($result) == 0)
+ return false;
+
+ $row = db_fetch_assoc($result);
+ return $row;