Merge branch '12.0' of git@github.com:Dolibarr/dolibarr.git into develop

This commit is contained in:
Laurent Destailleur 2020-08-06 03:04:46 +02:00
commit cd89538ee9

View File

@ -57,6 +57,7 @@ function dol_convertToWord($num, $langs, $currency = false, $centimes = false)
return $concatWords; return $concatWords;
} else { } else {
$TNum = explode('.', $num); $TNum = explode('.', $num);
$num = (int) $TNum[0]; $num = (int) $TNum[0];
$words = array(); $words = array();
$list1 = array( $list1 = array(
@ -138,12 +139,12 @@ function dol_convertToWord($num, $langs, $currency = false, $centimes = false)
} }
// If we need to write cents call again this function for cents // If we need to write cents call again this function for cents
if (!empty($TNum[1])) {
if (!empty($currency)) $concatWords .= ' '.$langs->transnoentities('and');
$decimalpart = $TNum[1]; $decimalpart = $TNum[1];
$decimalpart = preg_replace('/0+$/', '', $decimalpart); $decimalpart = preg_replace('/0+$/', '', $decimalpart);
if ($decimalpart) {
if (!empty($currency)) $concatWords .= ' '.$langs->transnoentities('and');
$concatWords .= ' '.dol_convertToWord($decimalpart, $langs, '', true); $concatWords .= ' '.dol_convertToWord($decimalpart, $langs, '', true);
if (!empty($currency)) $concatWords .= ' '.$langs->transnoentities('centimes'); if (!empty($currency)) $concatWords .= ' '.$langs->transnoentities('centimes');
} }
@ -163,10 +164,12 @@ function dol_convertToWord($num, $langs, $currency = false, $centimes = false)
*/ */
function dolNumberToWord($numero, $langs, $numorcurrency = 'number') function dolNumberToWord($numero, $langs, $numorcurrency = 'number')
{ {
// If the number is negative convert to positive and return -1 if is too long // If the number is negative convert to positive and return -1 if it is too long
if ($numero < 0) $numero *= -1; if ($numero < 0) $numero *= -1;
if ($numero >= 1000000000001) if ($numero >= 1000000000001) {
return -1; return -1;
}
// Get 2 decimals to cents, another functions round or truncate // Get 2 decimals to cents, another functions round or truncate
$strnumber = number_format($numero, 10); $strnumber = number_format($numero, 10);
$len = strlen($strnumber); $len = strlen($strnumber);