- if ($myrow['type'] == ST_SUPPRECEIVE || $myrow['type'] == ST_SUPPCREDIT)
- {
- $price = $myrow['price'];
- if ($myrow['type'] == ST_SUPPRECEIVE)
- {
- // Has the supplier invoice increased the receival price?
- $sql = "SELECT DISTINCT act_price
- FROM ".TB_PREF."purch_order_details pod
- INNER JOIN ".TB_PREF."grn_batch grn ON pod.order_no =
- grn.purch_order_no WHERE grn.id = ".$myrow['trans_no']." AND pod.item_code = '$stock_id'";
- $result = db_query($sql, "Could not retrieve act_price from purch_order_details");
- $row = db_fetch_row($result);
- if ($row[0] > 0 AND $row[0] <> $myrow['price'])
- $price = $row[0];
- }
- if ($myrow['person_id'] > 0)
- {
- // Do we have foreign currency?
- $supp = get_supplier($myrow['person_id']);
- $currency = $supp['curr_code'];
- $ex_rate = get_exchange_rate_to_home_currency($currency, sql2date($myrow['tran_date']));
- $price /= $ex_rate;
- }
- }
- elseif ($myrow['type'] != ST_INVADJUST) // calcutale the price from avg. price
- $price = ($myrow['standard_cost'] * $qty - $old_std_cost * $old_qty) / $myrow['qty'];
- else
- $price = $myrow['standard_cost']; // Item Adjustments just have the real cost
- return $price;
-}
+ if ($myrow['type'] == ST_SUPPRECEIVE || $myrow['type'] == ST_SUPPCREDIT)
+ {
+ $price = $myrow['price'];
+ if ($myrow['person_id'] > 0)
+ {
+ // Do we have foreign currency?
+ $supp = get_supplier($myrow['person_id']);
+ $currency = $supp['curr_code'];
+ $ex_rate = $myrow['ex_rate'];
+ $price *= $ex_rate;
+ }
+ }
+ else
+ $price = $myrow['standard_cost']; //pick standard_cost for sales deliveries
+
+ return $price;
+}