Skip to content

Commit 3ad93b9

Browse files
committed
ACP2E-420: Price in a Scheduled Update divided by 1000 depending on the Locale
1 parent 5d9fe40 commit 3ad93b9

File tree

2 files changed

+8
-21
lines changed
  • app/code/Magento
    • Catalog/Ui/DataProvider/Product/Form/Modifier
    • Ui/view/base/web/js/lib/validation

2 files changed

+8
-21
lines changed

app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Eav.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
class Eav extends AbstractModifier
5454
{
5555
public const SORT_ORDER_MULTIPLIER = 10;
56+
public const PRECISION = 2;
5657

5758
/**
5859
* @var LocatorInterface
@@ -1126,9 +1127,7 @@ protected function formatPrice($value)
11261127
return null;
11271128
}
11281129

1129-
$store = $this->storeManager->getStore();
1130-
$currency = $this->getLocaleCurrency()->getCurrency($store->getBaseCurrencyCode());
1131-
$value = $currency->toCurrency($value, ['display' => \Magento\Framework\Currency::NO_SYMBOL]);
1130+
$value = \Zend_Locale_Math::normalize(\Zend_Locale_Math::round($value, self::PRECISION));
11321131

11331132
return $value;
11341133
}

app/code/Magento/Ui/view/base/web/js/lib/validation/rules.js

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -605,36 +605,24 @@ define([
605605
],
606606
'validate-not-negative-number': [
607607
function (value) {
608-
if (utils.isEmptyNoTrim(value)) {
609-
return true;
610-
}
611-
value = utils.parseNumber(value);
612-
613-
return !isNaN(value) && value >= 0;
608+
return utils.isEmptyNoTrim(value) || !isNaN(utils.parseNumber(value))
609+
&& value >= 0 && (/^\s*-?\d+([,.]\d+)*\s*%?\s*$/).test(value);
614610

615611
},
616612
$.mage.__('Please enter a number 0 or greater in this field.')
617613
],
618614
// validate-not-negative-number should be replaced in all places with this one and then removed
619615
'validate-zero-or-greater': [
620616
function (value) {
621-
if (utils.isEmptyNoTrim(value)) {
622-
return true;
623-
}
624-
value = utils.parseNumber(value);
625-
626-
return !isNaN(value) && value >= 0;
617+
return utils.isEmptyNoTrim(value) || !isNaN(utils.parseNumber(value))
618+
&& value >= 0 && (/^\s*-?\d+([,.]\d+)*\s*%?\s*$/).test(value);
627619
},
628620
$.mage.__('Please enter a number 0 or greater in this field.')
629621
],
630622
'validate-greater-than-zero': [
631623
function (value) {
632-
if (utils.isEmptyNoTrim(value)) {
633-
return true;
634-
}
635-
value = utils.parseNumber(value);
636-
637-
return !isNaN(value) && value > 0;
624+
return utils.isEmptyNoTrim(value) || !isNaN(utils.parseNumber(value))
625+
&& value > 0 && (/^\s*-?\d+([,.]\d+)*\s*%?\s*$/).test(value);
638626
},
639627
$.mage.__('Please enter a number greater than 0 in this field.')
640628
],

0 commit comments

Comments
 (0)