Skip to content

Commit 252b199

Browse files
committed
- Removed hard coded precision in PriceCurrency class.
- PriceCurrency now uses the DEFAULT_PRECISION constant for rounding. - Cleanup convertAndRound function, so rounding only takes place in one function.
1 parent ee11eb6 commit 252b199

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

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

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,7 @@ public function convert($amount, $scope = null, $currency = null)
6262
*/
6363
public function convertAndRound($amount, $scope = null, $currency = null, $precision = self::DEFAULT_PRECISION)
6464
{
65-
$currentCurrency = $this->getCurrency($scope, $currency);
66-
$convertedValue = $this->getStore($scope)->getBaseCurrency()->convert($amount, $currentCurrency);
67-
return round($convertedValue, $precision);
65+
return $this->round($this->convert($amount, $scope, $currency), $precision);
6866
}
6967

7068
/**
@@ -148,13 +146,10 @@ protected function getStore($scope = null)
148146
}
149147

150148
/**
151-
* Round price
152-
*
153-
* @param float $price
154-
* @return float
149+
* {@inheritdoc}
155150
*/
156-
public function round($price)
151+
public function round($price, $precision = self::DEFAULT_PRECISION)
157152
{
158-
return round($price, 2);
153+
return round($price, $precision);
159154
}
160155
}

lib/internal/Magento/Framework/Pricing/PriceCurrencyInterface.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,10 @@ public function convertAndFormat(
7979
* Round price
8080
*
8181
* @param float $price
82+
* @param int $precision
8283
* @return float
8384
*/
84-
public function round($price);
85+
public function round($price, $precision = self::DEFAULT_PRECISION);
8586

8687
/**
8788
* Get currency model

0 commit comments

Comments
 (0)