FIX If using a rounding step, localtax1+2 not included in total

This commit is contained in:
Laurent Destailleur 2020-07-19 01:47:17 +02:00
parent 48adeb9dd7
commit f26a64fb88
2 changed files with 2 additions and 51 deletions

View File

@ -302,55 +302,6 @@ if (empty($mysoc->country_code))
print " - ".$langs->trans("VAT").": ".$vat.'%';
print ' &nbsp; -> &nbsp; <span class="opacitymedium">'.$langs->trans("TotalPriceAfterRounding").":</span> ".$tmparray[0].' / '.$tmparray[1].' / '.$tmparray[2]."<br>\n";
}
// Important: can debug rounding, to simulate the rounded total
/*
print '<br><b>'.$langs->trans("VATRoundedByLine").' ('.$langs->trans("DolibarrDefault").')</b><br>';
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 " &nbsp; -> &nbsp; ".$langs->trans("TotalPriceAfterRounding").": ".$total_ht.' / '.$total_tva.' / '.$total_ttc."<br>\n";
}
}
print '<br><b>'.$langs->trans("VATRoundedOnTotal").'</b><br>';
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 " &nbsp; -> &nbsp; ".$langs->trans("TotalPriceAfterRounding").": ".$total_ht.' / '.$total_tva.' / '.$total_ttc."<br>\n";
}
}
*/
}
// End of page

View File

@ -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');
}
}