Skip to content

Commit 993e00c

Browse files
committed
Merge branch 'ACP2E-1541' of https://github.com/magento-l3/magento2ce into PR-02142023
2 parents abdef2e + c526c6c commit 993e00c

File tree

2 files changed

+30
-7
lines changed

2 files changed

+30
-7
lines changed

app/code/Magento/Reports/Block/Adminhtml/Grid/Column/Renderer/Currency.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,10 @@ private function getStoreCurrencyRate(string $currencyCode, DataObject $row): fl
138138
$catalogPriceScope = $this->getCatalogPriceScope();
139139
$adminCurrencyCode = $this->getAdminCurrencyCode();
140140

141-
if (($catalogPriceScope != 0
141+
if (((int)$catalogPriceScope !== 0
142142
&& $adminCurrencyCode !== $currencyCode)) {
143-
$storeCurrency = $this->currencyFactory->create()->load($adminCurrencyCode);
144-
$currencyRate = $storeCurrency->getRate($currencyCode);
143+
$currency = $this->currencyFactory->create()->load($adminCurrencyCode);
144+
$currencyRate = $currency->getAnyRate($currencyCode);
145145
} else {
146146
$currencyRate = $this->_getRate($row);
147147
}

app/code/Magento/Reports/Test/Unit/Block/Adminhtml/Grid/Column/Renderer/CurrencyTest.php

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ protected function setUp(): void
181181
* @param string $storeCurrencyCode
182182
* @param string $adminOrderAmount
183183
* @param string $convertedAmount
184+
* @param bool $needToGetRateFromModel
184185
* @throws LocalizedException
185186
* @throws NoSuchEntityException
186187
* @throws CurrencyException
@@ -195,7 +196,8 @@ public function testRender(
195196
string $adminCurrencyCode,
196197
string $storeCurrencyCode,
197198
string $adminOrderAmount,
198-
string $convertedAmount
199+
string $convertedAmount,
200+
bool $needToGetRateFromModel
199201
): void {
200202
$this->row = new DataObject(
201203
[
@@ -252,6 +254,14 @@ public function testRender(
252254
->willReturn($currLocaleMock);
253255
$this->gridColumnMock->method('getCurrency')->willReturn('USD');
254256
$this->gridColumnMock->method('getRateField')->willReturn('test_rate_field');
257+
258+
if ($needToGetRateFromModel) {
259+
$this->currencyMock->expects($this->once())
260+
->method('getAnyRate')
261+
->with($storeCurrencyCode)
262+
->willReturn($rate);
263+
}
264+
255265
$actualAmount = $this->model->render($this->row);
256266
$this->assertEquals($convertedAmount, $actualAmount);
257267
}
@@ -272,7 +282,8 @@ public function getCurrencyDataProvider(): array
272282
'adminCurrencyCode' => 'EUR',
273283
'storeCurrencyCode' => 'EUR',
274284
'adminOrderAmount' => '105.00',
275-
'convertedAmount' => '105.00'
285+
'convertedAmount' => '105.00',
286+
'needToGetRateFromModel' => false
276287
],
277288
'rate conversion with different admin and storefront rate' => [
278289
'rate' => 1.4150,
@@ -282,8 +293,20 @@ public function getCurrencyDataProvider(): array
282293
'adminCurrencyCode' => 'USD',
283294
'storeCurrencyCode' => 'EUR',
284295
'adminOrderAmount' => '105.00',
285-
'convertedAmount' => '148.575'
286-
]
296+
'convertedAmount' => '148.575',
297+
'needToGetRateFromModel' => true
298+
],
299+
'rate conversation with same rate for different currencies' => [
300+
'rate' => 1.00,
301+
'columnIndex' => 'total_income_amount',
302+
'catalogPriceScope' => 1,
303+
'adminWebsiteId' => 1,
304+
'adminCurrencyCode' => 'USD',
305+
'storeCurrencyCode' => 'THB',
306+
'adminOrderAmount' => '100.00',
307+
'convertedAmount' => '100.00',
308+
'needToGetRateFromModel' => true
309+
],
287310
];
288311
}
289312

0 commit comments

Comments
 (0)