Add possibility to force the number of decimal in function price()

This commit is contained in:
Regis Houssin
2010-09-30 08:12:03 +00:00
parent 90f8dec16d
commit a2844b5575

View File

@@ -2360,17 +2360,18 @@ function vatrate($rate,$addpercent=false,$info_bits=0)
/** /**
* \brief Fonction qui formate un montant pour visualisation * Fonction qui formate un montant pour visualisation
* \remarks Fonction utilisee dans les pdf et les pages html * Fonction utilisee dans les pdf et les pages html
* \param amount Montant a formater * @param amount Montant a formater
* \param html Type de formatage, html ou pas (par defaut) * @param html Type de formatage, html ou pas (par defaut)
* \param outlangs Objet langs pour formatage text * @param outlangs Objet langs pour formatage text
* \param trunc 1=Tronque affichage si trop de decimales,0=Force le non troncage * @param trunc 1=Tronque affichage si trop de decimales,0=Force le non troncage
* \param rounding Minimum number of decimal. If not defined we use min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOTAL) * @param rounding Minimum number of decimal. If not defined we use min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOTAL)
* \return string Chaine avec montant formate * @param forcerounding Force the number of decimal
* \seealso price2num Revert function of price * @return string Chaine avec montant formate
* @see price2num Revert function of price
*/ */
function price($amount, $html=0, $outlangs='', $trunc=1, $rounding=-1) function price($amount, $html=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1)
{ {
global $langs,$conf; global $langs,$conf;
@@ -2412,6 +2413,9 @@ function price($amount, $html=0, $outlangs='', $trunc=1, $rounding=-1)
$end='...'; $end='...';
} }
} }
// If force rounding
if ($forcerounding >= 0) $nbdecimal = $forcerounding;
// Format number // Format number
if ($html) if ($html)