Skip to content

Commit dd2f602

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

File tree

3 files changed

+138
-43
lines changed

3 files changed

+138
-43
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@
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']"/>
1314
</section>
1415
</sections>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="AdminOrderReportsForMultiWebsiteWithDifferentDisplayCurrencyTest">
12+
<annotations>
13+
<features value="Sales"/>
14+
<stories value="Admin Order Reports For Multi Website With Different Display Currency(USD And EUR) Test"/>
15+
<title value="Admin Order Reports For Multi Website With Different Display Currency Test"/>
16+
<description value="Admin Order Reports For Multi Website With Different Display Currency Test"/>
17+
<severity value="MAJOR"/>
18+
<testCaseId value="ACP2E-3276"/>
19+
<group value="reports"/>
20+
</annotations>
21+
<before>
22+
<magentoCLI command="config:set {{StorefrontEnableAddStoreCodeToUrls.path}} {{StorefrontEnableAddStoreCodeToUrls.value}}" stepKey="addStoreCodeToUrlEnable"/>
23+
<!--Set catalog price scope to Global-->
24+
<comment userInput="Set catalog price scope to Website" stepKey="commentSetPriceScope"/>
25+
<magentoCLI command="config:set catalog/price/scope 1" stepKey="setPriceScopeWebsite"/>
26+
<createData entity="SimpleProduct2" stepKey="createProduct"/>
27+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
28+
29+
<actionGroup ref="AdminCreateWebsiteActionGroup" stepKey="createWebsite">
30+
<argument name="newWebsiteName" value="{{customWebsite.name}}"/>
31+
<argument name="websiteCode" value="{{customWebsite.code}}"/>
32+
</actionGroup>
33+
<actionGroup ref="AdminCreateNewStoreGroupActionGroup" stepKey="createNewStore">
34+
<argument name="website" value="{{customWebsite.name}}"/>
35+
<argument name="storeGroupName" value="{{customStoreGroup.name}}"/>
36+
<argument name="storeGroupCode" value="{{customStoreGroup.code}}"/>
37+
</actionGroup>
38+
<actionGroup ref="AdminCreateStoreViewActionGroup" stepKey="createCustomStoreView">
39+
<argument name="StoreGroup" value="customStoreGroup"/>
40+
<argument name="customStore" value="customStore"/>
41+
</actionGroup>
42+
<actionGroup ref="AdminProductPageOpenByIdActionGroup" stepKey="goToProductEditPage">
43+
<argument name="productId" value="$createProduct.id$"/>
44+
</actionGroup>
45+
<actionGroup ref="ProductSetWebsiteActionGroup" stepKey="assignProductToSecondWebsite">
46+
<argument name="website" value="{{customWebsite.name}}"/>
47+
</actionGroup>
48+
<actionGroup ref="AdminNavigateToCurrencySetupPageActionGroup" stepKey="goToCurrencySetupPage"/>
49+
<actionGroup ref="AdminSwitchWebsiteActionGroup" stepKey="switchToMainWebsite">
50+
<argument name="website" value="customWebsite"/>
51+
</actionGroup>
52+
<uncheckOption selector="{{AdminConfigSection.allowedCurrencyCheckbox}}" stepKey="uncheckUseSystemValueDisplayCurrency"/>
53+
<uncheckOption selector="{{AdminConfigSection.defaultCurrencyCheckbox}}" stepKey="uncheckUseSystemValueAllowedCurrency"/>
54+
<selectOption selector="{{AdminConfigSection.defaultCurrency}}" userInput="Euro" stepKey="selectAllowedDisplayCurrency"/>
55+
<selectOption selector="{{AdminConfigSection.allowedCurrencies}}" parameterArray="['Euro']" stepKey="selectDefaultDisplayCurrency"/>
56+
<actionGroup ref="SaveStoreConfigurationActionGroup" stepKey="saveStoreConfiguration"/>
57+
58+
<actionGroup ref="AdminOpenCurrencyRatesPageActionGroup" stepKey="gotToCurrencyRatesPageSecondTime"/>
59+
<comment userInput="Adding the comment to replace action for preserving Backward Compatibility" stepKey="waitForLoadRatesPageSecondTime"/>
60+
<actionGroup ref="AdminSetCurrencyRatesActionGroup" stepKey="setCurrencyRates">
61+
<argument name="firstCurrency" value="USD"/>
62+
<argument name="secondCurrency" value="EUR"/>
63+
<argument name="rate" value="0.8"/>
64+
</actionGroup>
65+
66+
</before>
67+
<after>
68+
<magentoCLI command="config:set {{StorefrontDisableAddStoreCodeToUrls.path}} {{StorefrontDisableAddStoreCodeToUrls.value}}" stepKey="addStoreCodeToUrlDisable"/>
69+
<magentoCLI command="config:set catalog/price/scope 1" stepKey="setCatalogPriceScopeToGlobal"/>
70+
<deleteData createDataKey="createProduct" stepKey="deleteProduct"/>
71+
<actionGroup ref="AdminOrdersGridClearFiltersActionGroup" stepKey="clearOrdersFilters"/>
72+
<actionGroup ref="AdminDeleteWebsiteActionGroup" stepKey="deleteWebsite">
73+
<argument name="websiteName" value="{{customWebsite.name}}"/>
74+
</actionGroup>
75+
</after>
76+
<!--Create customer account for Second Website-->
77+
<actionGroup ref="StorefrontOpenProductPageUsingStoreCodeInUrlActionGroup" stepKey="openProductPageUsingStoreCodeInUrl">
78+
<argument name="product" value="$createProduct$"/>
79+
<argument name="storeView" value="customStore"/>
80+
</actionGroup>
81+
<actionGroup ref="StorefrontAddToTheCartActionGroup" stepKey="addProductToCart"/>
82+
<!-- Go to Checkout -->
83+
<actionGroup ref="GoToCheckoutFromMinicartActionGroup" stepKey="goToCheckoutFromMinicart"/>
84+
85+
<!-- Fill all required fields with valid data and select Flat Rate, price = 5, shipping -->
86+
<actionGroup ref="GuestCheckoutFillingShippingSectionActionGroup" stepKey="guestCheckoutFillingShipping">
87+
<argument name="shippingMethod" value="Flat Rate"/>
88+
<argument name="customerAddressVar" value="US_Address_CA" />
89+
</actionGroup>
90+
91+
<!-- Select payment solution -->
92+
<actionGroup ref="CheckoutSelectCheckMoneyOrderPaymentActionGroup" stepKey="clickCheckMoneyOrderPayment"/>
93+
94+
<!-- Place Order: order is successfully placed -->
95+
<actionGroup ref="ClickPlaceOrderActionGroup" stepKey="clickPlaceOrder"/>
96+
<grabTextFrom selector="{{CheckoutSuccessMainSection.orderNumber}}" stepKey="grabOrderNumberEUR"/>
97+
98+
<actionGroup ref="AdminGoToOrdersReportPageActionGroup" stepKey="goToOrdersReportPageActionGroup" />
99+
100+
<click selector="{{ReportMainSection.storeViewDropdown}}" stepKey="clickOrderReportWebsiteSwitchDropdown"/>
101+
<waitForElementVisible selector="{{ReportMainSection.websiteByName('Main Website')}}" stepKey="waitForOrderReportWebsiteAreVisible"/>
102+
<click selector="{{ReportMainSection.websiteByName(customWebsite.name)}}" stepKey="clickOrderReportWebsiteByName"/>
103+
<click selector="{{AdminConfirmationModalSection.ok}}" stepKey="confirmStoreSwitch"/>
104+
105+
<generateDate stepKey="generateEndDate" date="+1 day" format="m/d/Y"/>
106+
<generateDate stepKey="generateStartDate" date="-1 day" format="m/d/Y"/>
107+
108+
<actionGroup ref="GenerateOrderReportActionGroup" stepKey="generateReportOrderReportEUR">
109+
<argument name="orderFromDate" value="$generateStartDate"/>
110+
<argument name="orderToDate" value="$generateEndDate"/>
111+
</actionGroup>
112+
<waitForPageLoad stepKey="waitForGenerateReportOrderEUR"/>
113+
114+
<grabTextFrom selector="{{GeneratedReportSection.salesTotals}}" stepKey="grabOrderAmountEURO"/>
115+
<assertStringContainsString stepKey="checkOrderCurrencySymbolEuro">
116+
<actualResult type="variable">$grabOrderAmountEURO</actualResult>
117+
<expectedResult type="string">€</expectedResult>
118+
</assertStringContainsString>
119+
</test>
120+
</tests>

dev/tests/integration/testsuite/Magento/Reports/Controller/Adminhtml/Report/Sales/AdminOrderReports.php

Lines changed: 17 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,25 @@
77

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

10+
use Magento\Catalog\Helper\Data;
1011
use Magento\Catalog\Test\Fixture\Product as ProductFixture;
12+
use Magento\Checkout\Test\Fixture\PlaceOrder as PlaceOrderFixture;
1113
use Magento\Checkout\Test\Fixture\SetBillingAddress as SetBillingAddressFixture;
1214
use Magento\Checkout\Test\Fixture\SetDeliveryMethod as SetDeliveryMethodFixture;
1315
use Magento\Checkout\Test\Fixture\SetPaymentMethod as SetPaymentMethodFixture;
1416
use Magento\Checkout\Test\Fixture\SetShippingAddress as SetShippingAddressFixture;
1517
use Magento\Customer\Test\Fixture\Customer;
1618
use Magento\Directory\Test\Fixture\CurrencyRate;
19+
use Magento\Framework\App\Config\ScopeConfigInterface;
20+
use Magento\Framework\App\ObjectManager;
1721
use Magento\Framework\Exception\CouldNotSaveException;
1822
use Magento\Framework\Exception\LocalizedException;
1923
use Magento\Framework\Exception\NoSuchEntityException;
2024
use Magento\Framework\Exception\StateException;
2125
use Magento\Framework\View\LayoutInterface;
22-
use Magento\Quote\Api\CartManagementInterface;
23-
use Magento\Quote\Api\CartRepositoryInterface;
2426
use Magento\Quote\Test\Fixture\AddProductToCart as AddProductToCartFixture;
2527
use Magento\Quote\Test\Fixture\CustomerCart;
26-
use Magento\Sales\Api\InvoiceOrderInterface;
27-
use Magento\Store\Model\ScopeInterface;
28-
use Magento\Store\Model\Store;
28+
use Magento\Sales\Test\Fixture\Invoice as InvoiceFixture;
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;
@@ -36,7 +36,6 @@
3636
use Magento\TestFramework\Fixture\DataFixtureStorage;
3737
use Magento\TestFramework\Fixture\DataFixtureStorageManager;
3838
use Magento\TestFramework\Fixture\DbIsolation;
39-
use Magento\TestFramework\Request;
4039
use Magento\TestFramework\TestCase\AbstractBackendController;
4140

4241
class AdminOrderReports extends AbstractBackendController
@@ -46,27 +45,9 @@ class AdminOrderReports extends AbstractBackendController
4645
*/
4746
private $fixtures;
4847

49-
/**
50-
* @var CartManagementInterface
51-
*/
52-
private $cartManagement;
53-
54-
/**
55-
* @var InvoiceOrderInterface
56-
*/
57-
private $invoiceOrder;
58-
59-
/**
60-
* @var CartRepositoryInterface
61-
*/
62-
private $quoteRepository;
63-
6448
protected function setUp(): void
6549
{
6650
parent::setUp();
67-
$this->cartManagement = $this->_objectManager->get(CartManagementInterface::class);
68-
$this->invoiceOrder = $this->_objectManager->get(InvoiceOrderInterface::class);
69-
$this->quoteRepository = $this->_objectManager->get(CartRepositoryInterface::class);
7051
$this->fixtures = $this->_objectManager->get(DataFixtureStorageManager::class)->getStorage();
7152
}
7253

@@ -78,18 +59,16 @@ protected function setUp(): void
7859
*/
7960
#[
8061
DbIsolation(false),
81-
AppIsolation(true),
82-
AppArea('adminhtml'),
83-
Config('catalog/price/scope', Store::PRICE_SCOPE_WEBSITE),
84-
DataFixture(WebsiteFixture::class, as: 'website2'),
62+
Config(Data::XML_PATH_PRICE_SCOPE, Data::PRICE_SCOPE_WEBSITE),
63+
DataFixture(WebsiteFixture::class, ['code' => 'website2'], as: 'website2'),
8564
DataFixture(StoreGroupFixture::class, ['website_id' => '$website2.id$'], 'group2'),
86-
DataFixture(StoreFixture::class, ['website_id' => '$website2.id$'], 'store2'),
87-
Config('currency/options/default', 'EUR', 'website', '$website2.code$'),
88-
Config('currency/options/allow', 'EUR', 'website', '$website2.code$'),
65+
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'),
8968
DataFixture(CurrencyRate::class, ['USD' => ['EUR' => '0.8']]),
9069
DataFixture(ProductFixture::class, ['website_ids' => [1, '$website2.id$']], as: 'p1'),
91-
DataFixture(Customer::class, ['website_id' => '$website2.id$'], as: 'customer'),
92-
DataFixture(CustomerCart::class, ['customer_id' => '$customer.id$'], as: 'cart'),
70+
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'),
9372
DataFixture(
9473
AddProductToCartFixture::class,
9574
['cart_id' => '$cart.id$', 'product_id' => '$p1.id$', 'qty' => 1]
@@ -98,20 +77,14 @@ protected function setUp(): void
9877
DataFixture(SetShippingAddressFixture::class, ['cart_id' => '$cart.id$'], as: 'shippingAddress'),
9978
DataFixture(SetDeliveryMethodFixture::class, ['cart_id' => '$cart.id$']),
10079
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'),
10182
]
10283
public function testAdminOrderReportsForMultiWebsiteWithDifferentDisplayCurrency()
10384
{
104-
$cart = $this->fixtures->get('cart');
105-
$storeId = $this->fixtures->get('store2')->getId();
106-
$websiteId = (int) $this->fixtures->get('website2')->getId();
107-
108-
$cart->setStoreId($storeId);
109-
$this->quoteRepository->save($cart);
85+
$scopeConfig = ObjectManager::getInstance()->get(ScopeConfigInterface::class);
11086

111-
$orderId = $this->cartManagement->placeOrder($cart->getId());
112-
$this->assertNotEmpty($orderId);
113-
$invoiceId = $this->invoiceOrder->execute($orderId);
114-
$this->assertNotEmpty($invoiceId);
87+
$websiteId = (int) $this->fixtures->get('website2')->getId();
11588

11689
$this->_objectManager->create('Magento\Sales\Model\ResourceModel\Report\Order')->aggregate();
11790

@@ -130,6 +103,7 @@ public function testAdminOrderReportsForMultiWebsiteWithDifferentDisplayCurrency
130103
$filterData = base64_encode(http_build_query($requestArray));
131104
$this->dispatch("backend/reports/report_sales/sales/website/{$websiteId}/filter/{$filterData}/");
132105
$this->assertEquals(200, $this->getResponse()->getHttpResponseCode());
106+
$body = $this->getResponse()->getBody();
133107
$layout = $this->_objectManager->get(LayoutInterface::class);
134108
$salesReportGrid = $layout->getBlock('adminhtml_sales_sales.grid');
135109
$blockHtml = $salesReportGrid->toHtml();

0 commit comments

Comments
 (0)