Skip to content

Commit dab892b

Browse files
committed
ACP2E-3276: Order reports showing the wrong currency symbol
1 parent dd2f602 commit dab892b

File tree

3 files changed

+47
-143
lines changed

3 files changed

+47
-143
lines changed

app/code/Magento/Reports/Test/Mftf/Section/OrderReportMainSection/GeneratedReportSection.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,5 @@
1010
<section name="GeneratedReportSection">
1111
<element name="ordersCount" type="text" selector="//tr[@class='totals']/th[@class=' col-orders col-orders_count col-number']"/>
1212
<element name="canceledOrders" type="text" selector="//tr[@class='totals']/th[@class=' col-canceled col-total_canceled_amount a-right']"/>
13-
<element name="salesTotals" type="text" selector="//tr[@class='totals']/th[@class=' col-sales-total col-total_income_amount a-right']"/>
1413
</section>
1514
</sections>

app/code/Magento/Reports/Test/Mftf/Test/AdminOrderReportsForMultiWebsiteWithDifferentDisplayCurrencyTest.xml

Lines changed: 0 additions & 120 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,78 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2024 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

88
namespace Magento\Reports\Controller\Adminhtml\Report\Sales;
99

1010
use Magento\Catalog\Helper\Data;
1111
use Magento\Catalog\Test\Fixture\Product as ProductFixture;
12-
use Magento\Checkout\Test\Fixture\PlaceOrder as PlaceOrderFixture;
1312
use Magento\Checkout\Test\Fixture\SetBillingAddress as SetBillingAddressFixture;
1413
use Magento\Checkout\Test\Fixture\SetDeliveryMethod as SetDeliveryMethodFixture;
1514
use Magento\Checkout\Test\Fixture\SetPaymentMethod as SetPaymentMethodFixture;
1615
use Magento\Checkout\Test\Fixture\SetShippingAddress as SetShippingAddressFixture;
1716
use Magento\Customer\Test\Fixture\Customer;
1817
use Magento\Directory\Test\Fixture\CurrencyRate;
19-
use Magento\Framework\App\Config\ScopeConfigInterface;
20-
use Magento\Framework\App\ObjectManager;
2118
use Magento\Framework\Exception\CouldNotSaveException;
2219
use Magento\Framework\Exception\LocalizedException;
2320
use Magento\Framework\Exception\NoSuchEntityException;
2421
use Magento\Framework\Exception\StateException;
2522
use Magento\Framework\View\LayoutInterface;
23+
use Magento\Quote\Api\CartManagementInterface;
2624
use Magento\Quote\Test\Fixture\AddProductToCart as AddProductToCartFixture;
2725
use Magento\Quote\Test\Fixture\CustomerCart;
28-
use Magento\Sales\Test\Fixture\Invoice as InvoiceFixture;
26+
use Magento\Sales\Api\InvoiceOrderInterface;
27+
use Magento\Store\Model\ScopeInterface;
28+
use Magento\Store\Model\StoreManagerInterface;
2929
use Magento\Store\Test\Fixture\Group as StoreGroupFixture;
3030
use Magento\Store\Test\Fixture\Store as StoreFixture;
3131
use Magento\Store\Test\Fixture\Website as WebsiteFixture;
32-
use Magento\TestFramework\Fixture\AppArea;
33-
use Magento\TestFramework\Fixture\AppIsolation;
3432
use Magento\TestFramework\Fixture\Config;
3533
use Magento\TestFramework\Fixture\DataFixture;
3634
use Magento\TestFramework\Fixture\DataFixtureStorage;
3735
use Magento\TestFramework\Fixture\DataFixtureStorageManager;
3836
use Magento\TestFramework\Fixture\DbIsolation;
3937
use Magento\TestFramework\TestCase\AbstractBackendController;
4038

41-
class AdminOrderReports extends AbstractBackendController
39+
/**
40+
* Test for order reports.
41+
*/
42+
class AdminOrderReportsTest extends AbstractBackendController
4243
{
4344
/**
4445
* @var DataFixtureStorage
4546
*/
4647
private $fixtures;
4748

49+
/**
50+
* @var CartManagementInterface
51+
*/
52+
private $cartManagement;
53+
54+
/**
55+
* @var InvoiceOrderInterface
56+
*/
57+
private $invoiceOrder;
58+
59+
/**
60+
* @var StoreManagerInterface
61+
*/
62+
private $storeManager;
63+
4864
protected function setUp(): void
4965
{
5066
parent::setUp();
67+
$this->cartManagement = $this->_objectManager->get(CartManagementInterface::class);
68+
$this->invoiceOrder = $this->_objectManager->get(InvoiceOrderInterface::class);
5169
$this->fixtures = $this->_objectManager->get(DataFixtureStorageManager::class)->getStorage();
70+
$this->storeManager = $this->_objectManager->get(StoreManagerInterface::class);
5271
}
5372

5473
/**
74+
* Test to verify admin order reports for multi website with different display currency.
75+
*
5576
* @throws NoSuchEntityException
5677
* @throws CouldNotSaveException
5778
* @throws StateException
@@ -63,12 +84,12 @@ protected function setUp(): void
6384
DataFixture(WebsiteFixture::class, ['code' => 'website2'], as: 'website2'),
6485
DataFixture(StoreGroupFixture::class, ['website_id' => '$website2.id$'], 'group2'),
6586
DataFixture(StoreFixture::class, ['store_group_id' => '$group2.id$'], 'store2'),
66-
Config('currency/options/default', 'EUR', 'website', 'website2'),
67-
Config('currency/options/allow', 'EUR', 'website', 'website2'),
87+
Config('currency/options/default', 'EUR', ScopeInterface::SCOPE_WEBSITE, 'website2'),
88+
Config('currency/options/allow', 'EUR', ScopeInterface::SCOPE_WEBSITE, 'website2'),
6889
DataFixture(CurrencyRate::class, ['USD' => ['EUR' => '0.8']]),
6990
DataFixture(ProductFixture::class, ['website_ids' => [1, '$website2.id$']], as: 'p1'),
7091
DataFixture(Customer::class, ['store_id' => '$store2.id$', 'website_id' => '$website2.id$'], as: 'customer'),
71-
DataFixture(CustomerCart::class, ['customer_id' => '$customer.id$', 'currency' => 'EUR'], as: 'cart', scope: 'store2'),
92+
DataFixture(CustomerCart::class, ['customer_id' => '$customer.id$'], as: 'cart', scope: 'store2'),
7293
DataFixture(
7394
AddProductToCartFixture::class,
7495
['cart_id' => '$cart.id$', 'product_id' => '$p1.id$', 'qty' => 1]
@@ -77,36 +98,40 @@ protected function setUp(): void
7798
DataFixture(SetShippingAddressFixture::class, ['cart_id' => '$cart.id$'], as: 'shippingAddress'),
7899
DataFixture(SetDeliveryMethodFixture::class, ['cart_id' => '$cart.id$']),
79100
DataFixture(SetPaymentMethodFixture::class, ['cart_id' => '$cart.id$']),
80-
DataFixture(PlaceOrderFixture::class, ['cart_id' => '$cart.id$'], 'order'),
81-
DataFixture(InvoiceFixture::class, ['order_id' => '$order.id$'], 'invoice'),
82101
]
83102
public function testAdminOrderReportsForMultiWebsiteWithDifferentDisplayCurrency()
84103
{
85-
$scopeConfig = ObjectManager::getInstance()->get(ScopeConfigInterface::class);
86-
104+
$cart = $this->fixtures->get('cart');
87105
$websiteId = (int) $this->fixtures->get('website2')->getId();
88106

107+
$store = $this->storeManager->getStore();
108+
$store->setCurrentCurrencyCode('EUR');
109+
110+
$orderId = $this->cartManagement->placeOrder($cart->getId());
111+
$this->assertNotEmpty($orderId);
112+
$invoiceId = $this->invoiceOrder->execute($orderId);
113+
$this->assertNotEmpty($invoiceId);
114+
89115
$this->_objectManager->create('Magento\Sales\Model\ResourceModel\Report\Order')->aggregate();
90116

91-
$beforeCurrentdate = date('m-d-Y', strtotime('-1 day'));
92-
$afterCurrentdate = date('m-d-Y', strtotime('+1 day'));
117+
$beforeCurrentDate = date('m-d-Y', strtotime('-1 day'));
118+
$afterCurrentDate = date('m-d-Y', strtotime('+1 day'));
93119

94120
$requestArray = [
95121
'report_type' => 'created_at_order',
96122
'period_type' => 'day',
97-
'from' => $beforeCurrentdate,
98-
'to' => $afterCurrentdate,
123+
'from' => $beforeCurrentDate,
124+
'to' => $afterCurrentDate,
99125
'show_order_statuses' => '0',
100126
'show_empty_rows' => '0',
101127
'show_actual_columns' => '0',
102128
];
103129
$filterData = base64_encode(http_build_query($requestArray));
104130
$this->dispatch("backend/reports/report_sales/sales/website/{$websiteId}/filter/{$filterData}/");
105131
$this->assertEquals(200, $this->getResponse()->getHttpResponseCode());
106-
$body = $this->getResponse()->getBody();
107132
$layout = $this->_objectManager->get(LayoutInterface::class);
108133
$salesReportGrid = $layout->getBlock('adminhtml_sales_sales.grid');
109134
$blockHtml = $salesReportGrid->toHtml();
110-
$this->assertNotEmpty($blockHtml);
135+
$this->assertStringContainsString('', $blockHtml);
111136
}
112137
}

0 commit comments

Comments
 (0)