Skip to content

Commit 15986b5

Browse files
committed
MAGETWO-53795: [Github] Ups shipping method CNY vs RMB currencycode problem
1 parent 046a7a8 commit 15986b5

File tree

3 files changed

+18
-47
lines changed

3 files changed

+18
-47
lines changed

app/code/Magento/Directory/Model/Currency.php

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -410,22 +410,6 @@ public function saveRates($rates)
410410
return $this;
411411
}
412412

413-
/**
414-
* Map currency alias to currency code
415-
*
416-
* @param string $code
417-
* @return string
418-
*/
419-
public function mapCurrencyCode($code)
420-
{
421-
$currencyMapping = [
422-
'RMB' => 'CNY',
423-
'CNH' => 'CNY'
424-
];
425-
426-
return isset($currencyMapping[$code]) ? $currencyMapping[$code] : $code;
427-
}
428-
429413
/**
430414
* This method removes LRM and RLM marks from string
431415
*

app/code/Magento/Directory/Test/Unit/Model/CurrencyTest.php

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -53,32 +53,6 @@ public function testGetCurrencySymbol()
5353
$this->assertEquals($currencySymbol, $this->currency->getCurrencySymbol());
5454
}
5555

56-
/**
57-
* @dataProvider mapCurrencyCodeDataProvider
58-
* @param string $currencyCode
59-
* @param string $expected
60-
*/
61-
public function testMapCurrencyCode($currencyCode, $expected)
62-
{
63-
static::assertEquals(
64-
$expected,
65-
$this->currency->mapCurrencyCode($currencyCode)
66-
);
67-
}
68-
69-
/**
70-
* Return data sets for testMapCurrencyCode()
71-
*
72-
* @return array
73-
*/
74-
public function mapCurrencyCodeDataProvider()
75-
{
76-
return [
77-
['RMB', 'CNY'],
78-
['CNH', 'CNY'],
79-
['USD', 'USD']
80-
];
81-
}
8256
/**
8357
* @dataProvider getOutputFormatDataProvider
8458
* @param $withCurrency

app/code/Magento/Ups/Model/Carrier.php

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,22 @@ protected function _getBaseCurrencyRate($code)
771771
return $this->_baseCurrencyRate;
772772
}
773773

774+
/**
775+
* Map currency alias to currency code
776+
*
777+
* @param string $code
778+
* @return string
779+
*/
780+
private function mapCurrencyCode($code)
781+
{
782+
$currencyMapping = [
783+
'RMB' => 'CNY',
784+
'CNH' => 'CNY'
785+
];
786+
787+
return isset($currencyMapping[$code]) ? $currencyMapping[$code] : $code;
788+
}
789+
774790
/**
775791
* Prepare shipping rate result based on response
776792
*
@@ -799,10 +815,7 @@ protected function _parseXmlResponse($xmlResponse)
799815
'shipper_number'
800816
) && !empty($negotiatedArr);
801817

802-
/** @var \Magento\Directory\Model\Currency $currency */
803-
$currency = $this->_currencyFactory->create();
804-
$allowedCurrencies = $currency->getConfigAllowCurrencies();
805-
818+
$allowedCurrencies = $this->_currencyFactory->create()->getConfigAllowCurrencies();
806819
foreach ($arr as $shipElement) {
807820
$code = (string)$shipElement->Service->Code;
808821
if (in_array($code, $allowedMethods)) {
@@ -814,7 +827,7 @@ protected function _parseXmlResponse($xmlResponse)
814827

815828
//convert price with Origin country currency code to base currency code
816829
$successConversion = true;
817-
$responseCurrencyCode = $currency->mapCurrencyCode(
830+
$responseCurrencyCode = $this->mapCurrencyCode(
818831
(string)$shipElement->TotalCharges->CurrencyCode
819832
);
820833
if ($responseCurrencyCode) {

0 commit comments

Comments
 (0)