Merge pull request #15650 from atm-lena/12.0_FIX_PriceToNum_ConvertNegativToPositiv

pricetonum() - preg-replace() delete "-" negativ number
This commit is contained in:
Laurent Destailleur 2020-12-04 18:19:22 +01:00 committed by GitHub
commit e0b737b622
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4724,7 +4724,7 @@ function price2num($amount, $rounding = '', $option = 0)
if ($option != 1) { // If not a PHP number or unknown, we change or clean format
//print 'PP'.$amount.' - '.$dec.' - '.$thousand.' - '.intval($amount).'<br>';
if (!is_numeric($amount)) {
$amount = preg_replace('/[a-zA-Z\/\\\*\(\)\<\>\-]/', '', $amount);
$amount = preg_replace('/[a-zA-Z\/\\\*\(\)\<\>]/', '', $amount);
}
if ($option == 2 && $thousand == '.' && preg_match('/\.(\d\d\d)$/', (string) $amount)) { // It means the . is used as a thousand separator and string come frominput data, so 1.123 is 1123