diff --git a/htdocs/admin/limits.php b/htdocs/admin/limits.php
index 4da340e588c..caf2192a9a3 100644
--- a/htdocs/admin/limits.php
+++ b/htdocs/admin/limits.php
@@ -302,55 +302,6 @@ if (empty($mysoc->country_code))
print " - ".$langs->trans("VAT").": ".$vat.'%';
print ' -> '.$langs->trans("TotalPriceAfterRounding").": ".$tmparray[0].' / '.$tmparray[1].' / '.$tmparray[2]."
\n";
}
-
- // Important: can debug rounding, to simulate the rounded total
- /*
- print '
'.$langs->trans("VATRoundedByLine").' ('.$langs->trans("DolibarrDefault").')
';
-
- foreach($vat_rates as $vat)
- {
- for ($qty=1; $qty<=2; $qty++)
- {
- $s1=10/3;
- $s2=2/7;
-
- // Round by line
- $tmparray1=calcul_price_total(1,$qty*price2num($s1,'MU'),0,$vat,0,0,0,'HT',0, 0,$mysoc);
- $tmparray2=calcul_price_total(1,$qty*price2num($s2,'MU'),0,$vat,0,0,0,'HT',0, 0,$mysoc);
- $total_ht = $tmparray1[0] + $tmparray2[0];
- $total_tva = $tmparray1[1] + $tmparray2[1];
- $total_ttc = $tmparray1[2] + $tmparray2[2];
-
- print $langs->trans("UnitPriceOfProduct").": ".(price2num($s1,'MU') + price2num($s2,'MU'));
- print " x ".$langs->trans("Quantity").": ".$qty;
- print " - ".$langs->trans("VAT").": ".$vat.'%';
- print " -> ".$langs->trans("TotalPriceAfterRounding").": ".$total_ht.' / '.$total_tva.' / '.$total_ttc."
\n";
- }
- }
-
- print '
'.$langs->trans("VATRoundedOnTotal").'
';
-
- foreach($vat_rates as $vat)
- {
- for ($qty=1; $qty<=2; $qty++)
- {
- $s1=10/3;
- $s2=2/7;
-
- // Global round
- $subtotal_ht = (($qty*price2num($s1,'MU')) + ($qty*price2num($s2,'MU')));
- $tmparray3=calcul_price_total(1,$subtotal_ht,0,$vat,0,0,0,'HT',0, 0,$mysoc);
- $total_ht = $tmparray3[0];
- $total_tva = $tmparray3[1];
- $total_ttc = $tmparray3[2];
-
- print $langs->trans("UnitPriceOfProduct").": ".price2num($s1+$s2,'MU');
- print " x ".$langs->trans("Quantity").": ".$qty;
- print " - ".$langs->trans("VAT").": ".$vat.'%';
- print " -> ".$langs->trans("TotalPriceAfterRounding").": ".$total_ht.' / '.$total_tva.' / '.$total_ttc."
\n";
- }
- }
- */
}
// End of page
diff --git a/htdocs/core/lib/price.lib.php b/htdocs/core/lib/price.lib.php
index c06c4431562..81c62958418 100644
--- a/htdocs/core/lib/price.lib.php
+++ b/htdocs/core/lib/price.lib.php
@@ -351,17 +351,17 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt
{
$result[0] = round($result[0] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT;
$result[1] = round($result[1] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT;
- $result[2] = price2num($result[0] + $result[1], 'MT');
$result[9] = round($result[9] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT;
$result[10] = round($result[10] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT;
+ $result[2] = price2num($result[0] + $result[1] + $result[9] + $result[10], 'MT');
}
else
{
$result[1] = round($result[1] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT;
$result[2] = round($result[2] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT;
- $result[0] = price2num($result[2] - $result[1], 'MT');
$result[9] = round($result[9] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT;
$result[10] = round($result[10] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT;
+ $result[0] = price2num($result[2] - $result[1] - $result[9] - $result[10], 'MT');
}
}