Merged changes from main trunk up to 2.2.5
[fa-stable.git] / sales / includes / sales_db.inc
index c350642ad05c605d792bf51bf0bfae1050c5a9d1..e9d7a95ef9b6372f1a4f4ba150ddba87bcf89726 100644 (file)
@@ -115,6 +115,23 @@ function get_price ($stock_id, $currency, $sales_type_id, $factor=null, $date=nu
            $prices[$myrow['sales_type_id']][$myrow['curr_abrev']] = $myrow['price'];
        }
        $price = false;
+       if (isset($prices[$sales_type_id][$currency])) 
+       {
+           $price = $prices[$sales_type_id][$currency];
+       }
+       elseif (isset($prices[$base_id][$currency])) 
+       {
+           $price = $prices[$base_id][$currency] * $factor;
+       }
+       elseif (isset($prices[$sales_type_id][$home_curr])) 
+       {
+           $price = $prices[$sales_type_id][$home_curr] / $rate;
+       }
+       elseif (isset($prices[$base_id][$home_curr])) 
+       {
+           $price = $prices[$base_id][$home_curr] * $factor / $rate;
+       }
+/*
        if (isset($prices[$sales_type_id][$home_curr])) 
        {
            $price = $prices[$sales_type_id][$home_curr] / $rate;
@@ -127,6 +144,7 @@ function get_price ($stock_id, $currency, $sales_type_id, $factor=null, $date=nu
        {
            $price = $prices[$base_id][$home_curr] * $factor / $rate;
        }
+*/     
        elseif ($num_rows == 0 && $add_pct != -1)
        {
                $price = get_calculated_price($stock_id, $add_pct);