Fixed: Average conversion rate insertion and currency sign issue resolved in order list

This commit is contained in:
Sumit Panwar
2023-10-12 18:39:01 +05:30
parent 3e09c4c2c5
commit 01392fd3a5
3 changed files with 12 additions and 6 deletions

View File

@@ -1840,7 +1840,9 @@ class OrderCore extends ObjectModel
}
// Whenever payment is adding in any order then set a cumulative conversion rate for the payment currency in the order
$this->conversion_rate = $order_payment->getCumulativeConversionRate($this->reference, $this->id_currency);
if ($avgConversionRate = $order_payment->getAverageConversionRate($this->reference, $this->id_currency)) {
$this->conversion_rate = $avgConversionRate;
}
$this->save();
return $res;

View File

@@ -150,12 +150,12 @@ class OrderPaymentCore extends ObjectModel
}
/**
* Provides the cumulative conversion rate for a given order in any currency
* Provides the average conversion rate for a given order in any currency
* @param [string] $order_reference
* @param [int] $idCurrency
* @return float
*/
public function getCumulativeConversionRate($order_reference, $idCurrency)
public function getAverageConversionRate($order_reference, $idCurrency)
{
return Db::getInstance()->getValue('SELECT (SUM(`conversion_rate`) / COUNT(*)) FROM `'._DB_PREFIX_.'order_payment` WHERE `order_reference` = \''.pSQL($order_reference).'\' AND `id_currency` = '.(int)$idCurrency);
}

View File

@@ -264,10 +264,14 @@ class AdminOrdersControllerCore extends AdminController
parent::__construct();
}
public static function setOrderCurrency($echo, $tr)
public static function setOrderCurrency($echo, $row)
{
$order = new Order($tr['id_order']);
return Tools::displayPrice($echo, (int)$order->id_currency);
if (Configuration::get('PS_ORDER_LIST_PRICE_DISPLAY_CURRENCY') == Order::ORDER_LIST_PRICE_DISPLAY_IN_DEFAULT_CURRENCY) {
$idCurrency = Configuration::get('PS_CURRENCY_DEFAULT');
} else {
$idCurrency = $row['id_currency'];
}
return Tools::displayPrice($echo, (int)$idCurrency);
}
public function renderForm()