From d684204bed339fba5573fdc7d30cd5454a8fac56 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 30 Mar 2023 16:33:24 +0200 Subject: [PATCH] Fix use MT rounding for cost price and margin on list of invoice --- htdocs/compta/facture/list.php | 8 ++++---- htdocs/core/lib/functions.lib.php | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 83b609f91f7..4a7485545a6 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -2430,7 +2430,7 @@ if ($resql) { } } if (!empty($arrayfields['multicurrency_dynamount_payed']['checked'])) { - print ''.(!empty($multicurrency_totalpay) ?price($multicurrency_totalpay, 0, $langs) : ' ').''; // TODO Use a denormalized field + print ''.(!empty($multicurrency_totalpay) ? price($multicurrency_totalpay, 0, $langs) : ' ').''; // TODO Use a denormalized field if (!$i) { $totalarray['nbfield']++; } @@ -2440,7 +2440,7 @@ if ($resql) { if (!empty($arrayfields['multicurrency_rtp']['checked'])) { print ''; print (!empty($multicurrency_remaintopay) ? price($multicurrency_remaintopay, 0, $langs) : ' '); - print ''; // TODO Use a denormalized field + print ''; // TODO Use a denormalized field ? if (!$i) { $totalarray['nbfield']++; } @@ -2448,14 +2448,14 @@ if ($resql) { // Total buying or cost price if (!empty($arrayfields['total_pa']['checked'])) { - print ''.price($marginInfo['pa_total']).''; + print ''.price($marginInfo['pa_total'], 0, $langs, 1, -1, 'MT').''; if (!$i) { $totalarray['nbfield']++; } } // Total margin if (!empty($arrayfields['total_margin']['checked'])) { - print ''.price($marginInfo['total_margin']).''; + print ''.price($marginInfo['total_margin'], 0, $langs, 1, -1, 'MT').''; if (!$i) { $totalarray['nbfield']++; } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index dc1f39aa43a..ef68d5c5ff2 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5740,8 +5740,8 @@ function vatrate($rate, $addpercent = false, $info_bits = 0, $usestarfornpr = 0, * @param integer $form Type of format, HTML or not (not by default) * @param Translate|string $outlangs Object langs for output. '' use default lang. 'none' use international separators. * @param int $trunc 1=Truncate if there is more decimals than MAIN_MAX_DECIMALS_SHOWN (default), 0=Does not truncate. Deprecated because amount are rounded (to unit or total amount accurancy) before beeing inserted into database or after a computation, so this parameter should be useless. - * @param int $rounding MINIMUM number of decimal to show. 0=no change, -1=we use min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOT) - * @param int|string $forcerounding Force the MAXIMUM of decimal to forcerounding decimal (-1=no change, 'MU' or 'MT' or numeric to round to MU or MT or to a given number of decimal) + * @param int $rounding MINIMUM number of decimal to show: 0=no change, -1=we use min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOT) + * @param int|string $forcerounding MAXIMUM number of decimal to forcerounding decimal: -1=no change, 'MU' or 'MT' or numeric to round to MU or MT or to a given number of decimal * @param string $currency_code To add currency symbol (''=add nothing, 'auto'=Use default currency, 'XXX'=add currency symbols for XXX currency) * @return string String with formated amount * @@ -5756,7 +5756,7 @@ function price($amount, $form = 0, $outlangs = '', $trunc = 1, $rounding = -1, $ $amount = 0; // To have a numeric value if amount not defined or = '' } $amount = (is_numeric($amount) ? $amount : 0); // Check if amount is numeric, for example, an error occured when amount value = o (letter) instead 0 (number) - if ($rounding < 0) { + if ($rounding == -1) { $rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT, $conf->global->MAIN_MAX_DECIMALS_TOT); } $nbdecimal = $rounding;