Skip to content
Code-Schnipsel Gruppen Projekte
Commit 720b3efc erstellt von Henning Leutz's avatar Henning Leutz :martial_arts_uniform:
Dateien durchsuchen
Übergeordneter 8e617953
Keine zugehörigen Branchen gefunden
Keine zugehörigen Tags gefunden
Keine zugehörigen Merge Requests gefunden
......@@ -44,16 +44,6 @@ class Price
*/
protected $User;
/**
* @var string
*/
protected static $decimalSeparator = ',';
/**
* @var string
*/
protected static $thousandsSeparator = '.';
/**
* Price constructor.
*
......@@ -210,26 +200,29 @@ public static function validatePrice($value)
$negativeTurn = -1;
}
$decimal = \mb_strpos($value, self::$decimalSeparator);
$thousands = \mb_strpos($value, self::$thousandsSeparator);
$decimalSeparator = QUI::getSystemLocale()->getDecimalSeparator();
$thousandSeparator = QUI::getSystemLocale()->getGroupingSeparator();
$decimal = \mb_strpos($value, $decimalSeparator);
$thousands = \mb_strpos($value, $thousandSeparator);
if ($thousands === false && $decimal === false) {
return \round(\floatval($value), 4) * $negativeTurn;
}
if ($thousands !== false && $decimal === false) {
if (\mb_substr($value, -4, 1) === self::$thousandsSeparator) {
$value = \str_replace(self::$thousandsSeparator, '', $value);
if (\mb_substr($value, -4, 1) === $thousandSeparator) {
$value = \str_replace($thousandSeparator, '', $value);
}
}
if ($thousands === false && $decimal !== false) {
$value = \str_replace(self::$decimalSeparator, '.', $value);
$value = \str_replace($decimalSeparator, '.', $value);
}
if ($thousands !== false && $decimal !== false) {
$value = \str_replace(self::$thousandsSeparator, '', $value);
$value = \str_replace(self::$decimalSeparator, '.', $value);
$value = \str_replace($thousandSeparator, '', $value);
$value = \str_replace($decimalSeparator, '.', $value);
}
return \round(\floatval($value), 4) * $negativeTurn;
......
0% Lade oder .
You are about to add 0 people to the discussion. Proceed with caution.
Bearbeitung dieser Nachricht zuerst beenden!
Bitte registrieren oder zum Kommentieren