Skip to content

Commit 85be7ff

Browse files
committed
ACP2E-3276: Order reports showing the wrong currency symbol
1 parent e1e01bb commit 85be7ff

File tree

2 files changed

+84
-8
lines changed

2 files changed

+84
-8
lines changed

app/code/Magento/Directory/Test/Fixture/CurrencyRate.php

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
11
<?php
2-
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
2+
/************************************************************************
3+
*
4+
* Copyright 2024 Adobe
5+
* All Rights Reserved.
6+
*
7+
* NOTICE: All information contained herein is, and remains
8+
* the property of Adobe and its suppliers, if any. The intellectual
9+
* and technical concepts contained herein are proprietary to Adobe
10+
* and its suppliers and are protected by all applicable intellectual
11+
* property laws, including trade secret and copyright laws.
12+
* Dissemination of this information or reproduction of this material
13+
* is strictly forbidden unless prior written permission is obtained
14+
* from Adobe.
15+
* ************************************************************************
516
*/
617
declare(strict_types=1);
718

@@ -11,6 +22,7 @@
1122
use Magento\Framework\App\ResourceConnection;
1223
use Magento\Framework\DataObject;
1324
use Magento\Framework\Locale\FormatInterface;
25+
use Magento\TestFramework\Fixture\Api\ServiceFactory;
1426
use Magento\TestFramework\Fixture\RevertibleDataFixtureInterface;
1527

1628
/**
@@ -24,9 +36,9 @@ class CurrencyRate implements RevertibleDataFixtureInterface
2436
private $format;
2537

2638
/**
27-
* @var Currency
39+
* @var ServiceFactory
2840
*/
29-
private $currency;
41+
private $serviceFactory;
3042

3143
/**
3244
* @var ResourceConnection
@@ -35,11 +47,11 @@ class CurrencyRate implements RevertibleDataFixtureInterface
3547

3648
public function __construct(
3749
FormatInterface $format,
38-
Currency $currency,
50+
ServiceFactory $serviceFactory,
3951
ResourceConnection $resourceConnection
4052
) {
4153
$this->format = $format;
42-
$this->currency = $currency;
54+
$this->serviceFactory = $serviceFactory;
4355
$this->resourceConnection = $resourceConnection;
4456
}
4557

@@ -52,7 +64,9 @@ public function apply(array $data = []): ?DataObject
5264
$data[$currencyCode][$currencyTo] = $value;
5365
}
5466
}
55-
$this->currency->saveRates($data);
67+
$service = $this->serviceFactory->create(Currency::class, 'saveRates');
68+
69+
return $service->execute(['rates' => $data]);
5670
}
5771
}
5872

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Reports\Controller\Adminhtml\Report\Sales;
9+
10+
use Magento\Catalog\Test\Fixture\Product as ProductFixture;
11+
use Magento\Checkout\Test\Fixture\PlaceOrder as PlaceOrderFixture;
12+
use Magento\Checkout\Test\Fixture\SetBillingAddress as SetBillingAddressFixture;
13+
use Magento\Checkout\Test\Fixture\SetDeliveryMethod as SetDeliveryMethodFixture;
14+
use Magento\Checkout\Test\Fixture\SetPaymentMethod as SetPaymentMethodFixture;
15+
use Magento\Checkout\Test\Fixture\SetShippingAddress as SetShippingAddressFixture;
16+
use Magento\Customer\Test\Fixture\Customer;
17+
use Magento\Directory\Test\Fixture\CurrencyRate;
18+
use Magento\Quote\Test\Fixture\AddProductToCart as AddProductToCartFixture;
19+
use Magento\Quote\Test\Fixture\CustomerCart;
20+
use Magento\Store\Model\ScopeInterface;
21+
use Magento\Store\Test\Fixture\Group as StoreGroupFixture;
22+
use Magento\Store\Test\Fixture\Store as StoreFixture;
23+
use Magento\Store\Test\Fixture\Website as WebsiteFixture;
24+
use Magento\TestFramework\Fixture\AppArea;
25+
use Magento\TestFramework\Fixture\Config as Config;
26+
use Magento\TestFramework\Fixture\DataFixture;
27+
use Magento\TestFramework\Fixture\DataFixtureStorageManager;
28+
use Magento\TestFramework\Fixture\DbIsolation;
29+
use Magento\TestFramework\Helper\Bootstrap;
30+
use Magento\TestFramework\TestCase\AbstractController;
31+
32+
class AdminOrderReports extends AbstractController
33+
{
34+
#[
35+
DbIsolation(false),
36+
AppArea('adminhtml'),
37+
Config('catalog/price/scope', 1),
38+
DataFixture(WebsiteFixture::class, as: 'website2'),
39+
DataFixture(StoreGroupFixture::class, ['website_id' => '$website2.id$'], 'group2'),
40+
DataFixture(StoreFixture::class, ['store_group_id' => '$group2.id$'], 'store2'),
41+
Config('currency/options/default', 'EUR', ScopeInterface::SCOPE_WEBSITE, '$website2.code$'),
42+
Config('currency/options/allow', 'EUR', ScopeInterface::SCOPE_WEBSITE, '$website2.code$'),
43+
DataFixture(CurrencyRate::class, ['USD' => ['EUR' => 0.8]]),
44+
DataFixture(ProductFixture::class, ['website_ids' => [1, '$website2.id$']], as: 'p1'),
45+
DataFixture(Customer::class, ['website_id' => '$website2.id$'], as: 'customer'),
46+
DataFixture(CustomerCart::class, ['customer_id' => '$customer.id$'], as: 'cart'),
47+
DataFixture(
48+
AddProductToCartFixture::class,
49+
['cart_id' => '$cart.id$', 'product_id' => '$p1.id$', 'qty' => 1]
50+
),
51+
DataFixture(SetBillingAddressFixture::class, ['cart_id' => '$cart.id$'], as: 'billingAddress'),
52+
DataFixture(SetShippingAddressFixture::class, ['cart_id' => '$cart.id$'], as: 'shippingAddress'),
53+
DataFixture(SetDeliveryMethodFixture::class, ['cart_id' => '$cart.id$']),
54+
DataFixture(SetPaymentMethodFixture::class, ['cart_id' => '$cart.id$']),
55+
DataFixture(PlaceOrderFixture::class, ['cart_id' => '$cart.id$'], as: 'order'),
56+
]
57+
public function testAdminOrderReportsForMultiWebsiteWithDifferentDisplayCurrencyT()
58+
{
59+
$order = Bootstrap::getObjectManager()->get(DataFixtureStorageManager::class)->getStorage()->get('order');
60+
$this->assertNotEmpty($order->getEntityId());
61+
}
62+
}

0 commit comments

Comments
 (0)