Fix: TTC must always be exactly HT + VAT
This commit is contained in:
parent
3ad74bb92b
commit
a66d44431d
@ -178,35 +178,35 @@ $tmparray=calcul_price_total(1,$qty*price2num($s,'MU'),0,$vat,0,0,0,'HT',0);
|
||||
print $langs->trans("UnitPriceOfProduct").": ".price2num($s,'MU');
|
||||
print " x ".$langs->trans("Quantity").": ".$qty;
|
||||
print " - ".$langs->trans("VAT").": ".$vat.'%';
|
||||
print " -> ".$langs->trans("TotalPriceAfterRounding").": ".$tmparray[2]."<br>\n";
|
||||
print " -> ".$langs->trans("TotalPriceAfterRounding").": ".$tmparray[0].' / '.$tmparray[1].' / '.$tmparray[2]."<br>\n";
|
||||
|
||||
$s=10/3;$qty=1;$vat=0;
|
||||
$tmparray=calcul_price_total(1,$qty*price2num($s,'MU'),0,$vat,0,0,0,'HT',0);
|
||||
print $langs->trans("UnitPriceOfProduct").": ".price2num($s,'MU');
|
||||
print " x ".$langs->trans("Quantity").": ".$qty;
|
||||
print " - ".$langs->trans("VAT").": ".$vat.'%';
|
||||
print " -> ".$langs->trans("TotalPriceAfterRounding").": ".$tmparray[2]."<br>\n";
|
||||
print " -> ".$langs->trans("TotalPriceAfterRounding").": ".$tmparray[0].' / '.$tmparray[1].' / '.$tmparray[2]."<br>\n";
|
||||
|
||||
$s=10/3;$qty=2;$vat=0;
|
||||
$tmparray=calcul_price_total(1,$qty*price2num($s,'MU'),0,$vat,0,0,0,'HT',0);
|
||||
print $langs->trans("UnitPriceOfProduct").": ".price2num($s,'MU');
|
||||
print " x ".$langs->trans("Quantity").": ".$qty;
|
||||
print " - ".$langs->trans("VAT").": ".$vat.'%';
|
||||
print " -> ".$langs->trans("TotalPriceAfterRounding").": ".$tmparray[2]."<br>\n";
|
||||
print " -> ".$langs->trans("TotalPriceAfterRounding").": ".$tmparray[0].' / '.$tmparray[1].' / '.$tmparray[2]."<br>\n";
|
||||
|
||||
$s=10/3;$qty=1;$vat=10;
|
||||
$tmparray=calcul_price_total(1,$qty*price2num($s,'MU'),0,$vat,0,0,0,'HT',0);
|
||||
print $langs->trans("UnitPriceOfProduct").": ".price2num($s,'MU');
|
||||
print " x ".$langs->trans("Quantity").": ".$qty;
|
||||
print " - ".$langs->trans("VAT").": ".$vat.'%';
|
||||
print " -> ".$langs->trans("TotalPriceAfterRounding").": ".$tmparray[2]."<br>\n";
|
||||
print " -> ".$langs->trans("TotalPriceAfterRounding").": ".$tmparray[0].' / '.$tmparray[1].' / '.$tmparray[2]."<br>\n";
|
||||
|
||||
$s=10/3;$qty=2;$vat=10;
|
||||
$tmparray=calcul_price_total(1,$qty*price2num($s,'MU'),0,$vat,0,0,0,'HT',0);
|
||||
print $langs->trans("UnitPriceOfProduct").": ".price2num($s,'MU');
|
||||
print " x ".$langs->trans("Quantity").": ".$qty;
|
||||
print " - ".$langs->trans("VAT").": ".$vat.'%';
|
||||
print " -> ".$langs->trans("TotalPriceAfterRounding").": ".$tmparray[2]."<br>\n";
|
||||
print " -> ".$langs->trans("TotalPriceAfterRounding").": ".$tmparray[0].' / '.$tmparray[1].' / '.$tmparray[2]."<br>\n";
|
||||
|
||||
$db->close();
|
||||
|
||||
|
||||
@ -744,7 +744,7 @@ MAIN_MAX_DECIMALS_SHOWN=Max decimals for prices shown on screen (Add <b>...</b>
|
||||
MAIN_DISABLE_PDF_COMPRESSION=Use PDF compression for generated PDF files.
|
||||
MAIN_ROUNDING_RULE_TOT= Size of rounding range (for rare countries where rounding is done on something else than base 10)
|
||||
UnitPriceOfProduct=Net unit price of a product
|
||||
TotalPriceAfterRounding=Total price inc. tax after rounding
|
||||
TotalPriceAfterRounding=Total price (net/vat/incl tax) after rounding
|
||||
ParameterActiveForNextInputOnly=Parameter effective for next input only
|
||||
NoEventOrNoAuditSetup=No security event has been recorded yet. This can be normal if audit has not been enabled on "setup - security - audit" page.
|
||||
NoEventFoundWithCriteria=No security event has been found for such search criterias.
|
||||
|
||||
@ -745,7 +745,7 @@ MAIN_MAX_DECIMALS_SHOWN= Nombre de décimales maximum pour les montant affichés
|
||||
MAIN_DISABLE_PDF_COMPRESSION= Utiliser la compression PDF pour les fichiers PDF générés.
|
||||
MAIN_ROUNDING_RULE_TOT= Taille du pas des arrondis (pour les très rares pays qui arrondissent sur une autre base que la base 10)
|
||||
UnitPriceOfProduct=Prix unitaire HT d'un produit
|
||||
TotalPriceAfterRounding=Prix total TTC après arrondis
|
||||
TotalPriceAfterRounding=Prix total (HT/TVA/TTC) après arrondis
|
||||
ParameterActiveForNextInputOnly= Paramètre effectif pour les prochaines saisies uniquement
|
||||
NoEventOrNoAuditSetup= Aucun événement d'audit de sécurité n'a été enregistré. Ceci peut être normal si l'audit n'a pas été activé dans la configuration - sécurité - audit.
|
||||
NoEventFoundWithCriteria= Aucun évéenement d'audit de sécurité trouvé avec ces critères.
|
||||
|
||||
@ -60,7 +60,7 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $txlocalta
|
||||
$result[0] = price2num($tot_avec_remise, 'MT');
|
||||
$result[2] = price2num($tot_avec_remise * ( 1 + ( (($info_bits & 1)?0:$txtva) / 100)), 'MT'); // Selon TVA NPR ou non
|
||||
$result2bis= price2num($tot_avec_remise * ( 1 + ( $txtva / 100)), 'MT'); // Si TVA consideree normale (non NPR)
|
||||
|
||||
|
||||
$result[1] = $result2bis - $result[0]; // Total VAT = TTC - HT
|
||||
|
||||
$result[3] = price2num($pu, 'MU');
|
||||
@ -83,7 +83,7 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $txlocalta
|
||||
$result[2] = price2num($tot_avec_remise, 'MT');
|
||||
$result[0] = price2num($tot_avec_remise / ( 1 + ((($info_bits & 1)?0:$txtva) / 100)), 'MT'); // Selon TVA NPR ou non
|
||||
$result0bis= price2num($tot_avec_remise / ( 1 + ($txtva / 100)), 'MT'); // Si TVA consideree normale (non NPR)
|
||||
|
||||
|
||||
$result[1] = $result[2] - $result0bis; // Total VAT = TTC - HT
|
||||
|
||||
$result[5] = price2num($pu, 'MU');
|
||||
@ -91,16 +91,16 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $txlocalta
|
||||
$result3bis= price2num($pu / ( 1 + ($txtva / 100)), 'MU'); // Si TVA consideree normale (non NPR)
|
||||
$result[4] = $result[5] - $result3bis;
|
||||
}
|
||||
|
||||
|
||||
//Local taxes
|
||||
if ($txlocaltax1>0)
|
||||
{
|
||||
$result[14] = price2num(($tot_sans_remise * ( 1 + ( $txlocaltax1 / 100))) - $tot_sans_remise, 'MT');
|
||||
$result[8] = $result[8] + $result[14];
|
||||
|
||||
|
||||
$result[9] = price2num(($tot_avec_remise * ( 1 + ( $txlocaltax1 / 100))) - $tot_avec_remise, 'MT');
|
||||
$result[2] = $result[2] + $result[9];
|
||||
|
||||
|
||||
$result[11] = price2num(($pu * ( 1 + ( $txlocaltax1 / 100))) - $pu, 'MT');
|
||||
$result[5] = $result[5] + $result[11];
|
||||
}
|
||||
@ -108,23 +108,35 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $txlocalta
|
||||
{
|
||||
$result[15] = price2num(($tot_sans_remise * ( 1 + ( $txlocaltax2 / 100))) - $tot_sans_remise, 'MT');
|
||||
$result[8] = $result[8] + $result[15];
|
||||
|
||||
|
||||
$result[10] = price2num(($tot_avec_remise * ( 1 + ( $txlocaltax2 / 100))) - $tot_avec_remise, 'MT');
|
||||
$result[2] = $result[2] + $result[10];
|
||||
|
||||
|
||||
$result[12] = price2num(($pu * ( 1 + ( $txlocaltax2 / 100))) - $pu, 'MT');
|
||||
$result[5] = $result[5] + $result[12];
|
||||
}
|
||||
|
||||
|
||||
// If rounding is not using base 10 (rare)
|
||||
if (! empty($conf->global->MAIN_ROUNDING_RULE_TOT))
|
||||
{
|
||||
$result[0]=round($result[0]/$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[1]=round($result[1]/$conf->global->MAIN_ROUNDING_RULE_TOT, 0)*$conf->global->MAIN_ROUNDING_RULE_TOT;
|
||||
$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;
|
||||
if ($price_base_type == 'HT')
|
||||
{
|
||||
$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]=$result[0]+$result[1];
|
||||
$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;
|
||||
}
|
||||
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]=$result[2]-$result[0];
|
||||
$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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//print "Price.lib::calcul_price_total ".$result[0]."-".$result[1]."-".$result[2];
|
||||
|
||||
return $result;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user