Merge pull request #876 from shreesh-webkul/gli-1606

Fixed: Currency conversion in admin stats page
This commit is contained in:
Rohit Jain
2024-03-17 14:46:36 +05:30
committed by GitHub
3 changed files with 7 additions and 3 deletions

View File

@@ -1823,7 +1823,11 @@ class OrderCore extends ObjectModel
$order_payment->order_reference = $this->reference;
$order_payment->id_currency = ($currency ? $currency->id : $this->id_currency);
// we kept the currency rate for historization reasons
$order_payment->conversion_rate = ($currency ? $currency->conversion_rate : 1);
$order_payment->conversion_rate = (
$currency ?
$currency->conversion_rate :
(new Currency($this->id_currency))->getConversationRate()
);
// if payment_method is define, we used this
$order_payment->payment_method = ($payment_method ? $payment_method : $this->payment);
$order_payment->payment_type = ($payment_type ? $payment_type : $this->payment_type);

View File

@@ -191,7 +191,7 @@ class StatsBestCategories extends ModuleGrid
AND hbd.`date_to` > "'.pSQL($date_from).'" AND hbd.`date_from` < "'.pSQL($date_to).'"
) AS totalOrders,
(
SELECT IFNULL(SUM(ROUND((DATEDIFF(LEAST(hbd.`date_to`, "'.pSQL($date_to).'"), GREATEST(hbd.`date_from`, "'.pSQL($date_from).'")) / DATEDIFF(hbd.`date_to`, hbd.`date_from`)) * hbd.`total_price_tax_excl`, 2)), 0)
SELECT IFNULL(SUM(ROUND((DATEDIFF(LEAST(hbd.`date_to`, "'.pSQL($date_to).'"), GREATEST(hbd.`date_from`, "'.pSQL($date_from).'")) / DATEDIFF(hbd.`date_to`, hbd.`date_from`)) * (hbd.`total_price_tax_excl` / o.`conversion_rate`), 2)), 0)
FROM `'._DB_PREFIX_.'htl_booking_detail` hbd
LEFT JOIN `'._DB_PREFIX_.'orders` o
ON (o.`id_order` = hbd.`id_order`)

View File

@@ -176,7 +176,7 @@ class StatsBestProducts extends ModuleGrid
AND hbd.`date_to` > "'.pSQL($date_from).'" AND hbd.`date_from` < "'.pSQL($date_to).'"
) AS sellingPrice,
(
SELECT IFNULL(SUM(ROUND((DATEDIFF(LEAST(hbd.`date_to`, "'.pSQL($date_to).'"), GREATEST(hbd.`date_from`, "'.pSQL($date_from).'")) / DATEDIFF(hbd.`date_to`, hbd.`date_from`)) * hbd.`total_price_tax_excl`, 2)), 0)
SELECT IFNULL(SUM(ROUND((DATEDIFF(LEAST(hbd.`date_to`, "'.pSQL($date_to).'"), GREATEST(hbd.`date_from`, "'.pSQL($date_from).'")) / DATEDIFF(hbd.`date_to`, hbd.`date_from`)) * (hbd.`total_price_tax_excl` / o.`conversion_rate`) , 2)), 0)
FROM `'._DB_PREFIX_.'htl_booking_detail` hbd
LEFT JOIN `'._DB_PREFIX_.'orders` o
ON (o.`id_order` = hbd.`id_order`)