Skip to content

Price tiers calculated on 2 decimals even when prices of 4 decimals are entered issue solved. #37942

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: 2.4-develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions app/code/Magento/Catalog/view/base/web/js/price-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@ define([
'use strict';

var globalPriceFormat = {
requiredPrecision: 2,
requiredPrecision:4,
integerRequired: 1,
decimalSymbol: ',',
groupSymbol: ',',
groupLength: ','
};

/**
* Repeats {string} {times} times
* @param {String} string
Expand All @@ -41,9 +40,8 @@ define([
{
var s = '',
precision, pattern, locale, r;

format = _.extend(globalPriceFormat, format);
precision = isNaN(format.requiredPrecision = Math.abs(format.requiredPrecision)) ? 2 : format.requiredPrecision;
precision = !isNaN(format.requiredPrecision = Math.abs(format.requiredPrecision)) ? format.requiredPrecision : 4;
pattern = format.pattern || '%s';
locale = window.LOCALE || 'en-US';
if (isShowSign === undefined || isShowSign === true) {
Expand Down Expand Up @@ -76,7 +74,7 @@ define([

precision = isNaN(format.requiredPrecision = Math.abs(format.requiredPrecision)) ? 2 : format.requiredPrecision;
integerRequired = isNaN(format.integerRequired = Math.abs(format.integerRequired)) ? 1 : format.integerRequired;
decimalSymbol = format.decimalSymbol === undefined ? ',' : format.decimalSymbol;
decimalSymbol = format.decimalSymbol === undefined ? '.' : format.decimalSymbol;
groupSymbol = format.groupSymbol === undefined ? '.' : format.groupSymbol;
groupLength = format.groupLength === undefined ? 3 : format.groupLength;
pattern = format.pattern || '%s';
Expand Down
3 changes: 1 addition & 2 deletions app/code/Magento/Directory/Model/PriceCurrency.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,8 @@ protected function getStore($scope = null)
*/
public function round($price)
{
return round((float) $price, 2);
return round((float) $price, self::DEFAULT_PRECISION);
}

/**
* Round price with precision
*
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Quote/Model/Quote/Item/AbstractItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,6 @@ public function calcRowTotal()
// Round unit price before multiplying to prevent losing 1 cent on subtotal
$total = $this->priceCurrency->round($this->getCalculationPriceOriginal()) * $qty;
$baseTotal = $this->priceCurrency->round($this->getBaseCalculationPriceOriginal()) * $qty;

$this->setRowTotal($this->priceCurrency->round($total));
$this->setBaseRowTotal($this->priceCurrency->round($baseTotal));
return $this;
Expand Down Expand Up @@ -582,6 +581,7 @@ public function setPrice($value)
*/
public function getConvertedPrice()
{

$price = $this->_getData('converted_price');
if ($price === null) {
$price = $this->priceCurrency->convert($this->getPrice(), $this->getStore());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/
interface PriceCurrencyInterface
{
const DEFAULT_PRECISION = 2;
const DEFAULT_PRECISION = 4;

/**
* Convert price value
Expand Down