Rename var to make debug easier

This commit is contained in:
Laurent Destailleur 2024-11-06 15:15:55 +01:00
parent 74ce8c6536
commit 00b9943069

View file

@ -59,8 +59,8 @@
* 1=total_vat, (main vat only)
* 2=total_ttc, (total_ht + main vat + local taxes)
* 3=pu_ht,
* 4=pu_vat, (main vat only)
* 5=pu_ttc,
* 4=pu_vat, (main vat only) !! should not be used
* 5=pu_ttc, !! should not be used except if it is stored in database one day
* 6=total_ht_without_discount,
* 7=total_vat_without_discount, (main vat only)
* 8=total_ttc_without_discount, (total_ht + main vat + local taxes)
@ -194,7 +194,7 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt
}
// initialize total (may be HT or TTC depending on price_base_type)
$tot_sans_remise = $pu * $qty * $progress / 100;
$tot_sans_remise = $pu * $qty * ($progress / 100);
$tot_avec_remise_ligne = $tot_sans_remise * (1 - ((float) $remise_percent_ligne / 100));
$tot_avec_remise = $tot_avec_remise_ligne * (1 - ((float) $remise_percent_global / 100));
@ -207,16 +207,26 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt
// if input unit price is 'HT', we need to have the totals with main VAT for a correct calculation
if ($price_base_type != 'TTC') {
$tot_sans_remise_wt = price2num($tot_sans_remise * (1 + ($txtva / 100)), 'MU');
$tot_avec_remise_wt = price2num($tot_avec_remise * (1 + ($txtva / 100)), 'MU');
$pu_wt = price2num($pu * (1 + ($txtva / 100)), 'MU');
$tot_sans_remise_withvat = price2num($tot_sans_remise * (1 + ($txtva / 100)), 'MU');
$tot_avec_remise_withvat = price2num($tot_avec_remise * (1 + ($txtva / 100)), 'MU');
$tot_sans_remise_withoutvat = $tot_sans_remise;
$tot_avec_remise_withoutvat = $tot_avec_remise;
$pu_withouttax = $pu;
$pu_withmainvat = price2num($pu * (1 + ($txtva / 100)), 'MU');
} else {
$tot_sans_remise_wt = $tot_sans_remise;
$tot_avec_remise_wt = $tot_avec_remise;
$pu_wt = $pu;
$tot_sans_remise_withvat = $tot_sans_remise;
$tot_avec_remise_withvat = $tot_avec_remise;
$tot_sans_remise_withoutvat = price2num($tot_sans_remise / (1 + ($txtva / 100)), 'MU');
$tot_avec_remise_withoutvat = price2num($tot_avec_remise / (1 + ($txtva / 100)), 'MU');
$pu_withouttax = price2num($pu / (1 + ($txtva / 100)), 'MU');
$pu_withmainvat = $pu;
}
//print 'rr'.$price_base_type.'-'.$txtva.'-'.$tot_sans_remise_wt."-".$pu_wt."-".$uselocaltax1_rate."-".$localtax1_rate."-".$localtax1_type."\n";
//print 'rr'.$price_base_type.'-'.$txtva.'-'.$tot_sans_remise_withvat."-".$pu_withmainvat."-".$uselocaltax1_rate."-".$localtax1_rate."-".$localtax1_type."\n";
$localtaxes = array(0, 0, 0);
$apply_tax = false;
@ -237,13 +247,13 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt
}
if ($uselocaltax1_rate && $apply_tax) {
$result[14] = price2num(($tot_sans_remise_wt * (1 + ($localtax1_rate / 100))) - $tot_sans_remise_wt, 'MT');
$result[14] = price2num(($tot_sans_remise_withvat * (1 + ($localtax1_rate / 100))) - $tot_sans_remise_withvat, 'MT');
$localtaxes[0] += $result[14];
$result[9] = price2num(($tot_avec_remise_wt * (1 + ($localtax1_rate / 100))) - $tot_avec_remise_wt, 'MT');
$result[9] = price2num(($tot_avec_remise_withvat * (1 + ($localtax1_rate / 100))) - $tot_avec_remise_withvat, 'MT');
$localtaxes[1] += $result[9];
$result[11] = price2num(($pu_wt * (1 + ($localtax1_rate / 100))) - $pu_wt, 'MU');
$result[11] = price2num(($pu_withmainvat * (1 + ($localtax1_rate / 100))) - $pu_withmainvat, 'MU');
$localtaxes[2] += $result[11];
}
@ -264,13 +274,13 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt
break;
}
if ($uselocaltax2_rate && $apply_tax) {
$result[15] = price2num(($tot_sans_remise_wt * (1 + ($localtax2_rate / 100))) - $tot_sans_remise_wt, 'MT');
$result[15] = price2num(($tot_sans_remise_withvat * (1 + ($localtax2_rate / 100))) - $tot_sans_remise_withvat, 'MT');
$localtaxes[0] += $result[15];
$result[10] = price2num(($tot_avec_remise_wt * (1 + ($localtax2_rate / 100))) - $tot_avec_remise_wt, 'MT');
$result[10] = price2num(($tot_avec_remise_withvat * (1 + ($localtax2_rate / 100))) - $tot_avec_remise_withvat, 'MT');
$localtaxes[1] += $result[10];
$result[12] = price2num(($pu_wt * (1 + ($localtax2_rate / 100))) - $pu_wt, 'MU');
$result[12] = price2num(($pu_withmainvat * (1 + ($localtax2_rate / 100))) - $pu_withmainvat, 'MU');
$localtaxes[2] += $result[12];
}
@ -311,13 +321,6 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt
// if there's some localtax without vat, we calculate localtaxes (we will add them at end)
//If input unit price is 'TTC', we need to have the totals without main VAT for a correct calculation
if ($price_base_type == 'TTC') {
$tot_sans_remise = price2num($tot_sans_remise / (1 + ($txtva / 100)), 'MU');
$tot_avec_remise = price2num($tot_avec_remise / (1 + ($txtva / 100)), 'MU');
$pu = price2num($pu / (1 + ($txtva / 100)), 'MU');
}
$apply_tax = false;
switch ($localtax1_type) {
case '1': // localtax on product or service
@ -335,13 +338,13 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt
break;
}
if ($uselocaltax1_rate && $apply_tax) {
$result[14] = price2num(($tot_sans_remise * (1 + ($localtax1_rate / 100))) - $tot_sans_remise, 'MT'); // amount tax1 for total_ht_without_discount
$result[14] = price2num(($tot_sans_remise_withoutvat * (1 + ($localtax1_rate / 100))) - $tot_sans_remise_withoutvat, 'MT'); // amount tax1 for total_ht_without_discount
$result[8] += $result[14]; // total_ttc_without_discount + tax1
$result[9] = price2num(($tot_avec_remise * (1 + ($localtax1_rate / 100))) - $tot_avec_remise, 'MT'); // amount tax1 for total_ht
$result[9] = price2num(($tot_avec_remise_withoutvat * (1 + ($localtax1_rate / 100))) - $tot_avec_remise_withoutvat, 'MT'); // amount tax1 for total_ht
$result[2] += $result[9]; // total_ttc + tax1
$result[11] = price2num(($pu * (1 + ($localtax1_rate / 100))) - $pu, 'MU'); // amount tax1 for pu_ht
$result[11] = price2num(($pu_withouttax * (1 + ($localtax1_rate / 100))) - $pu_withouttax, 'MU'); // amount tax1 for pu_ht
$result[5] += $result[11]; // pu_ht + tax1
}
@ -362,13 +365,13 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt
break;
}
if ($uselocaltax2_rate && $apply_tax) {
$result[15] = price2num(($tot_sans_remise * (1 + ($localtax2_rate / 100))) - $tot_sans_remise, 'MT'); // amount tax2 for total_ht_without_discount
$result[15] = price2num(($tot_sans_remise_withoutvat * (1 + ($localtax2_rate / 100))) - $tot_sans_remise_withoutvat, 'MT'); // amount tax2 for total_ht_without_discount
$result[8] += $result[15]; // total_ttc_without_discount + tax2
$result[10] = price2num(($tot_avec_remise * (1 + ($localtax2_rate / 100))) - $tot_avec_remise, 'MT'); // amount tax2 for total_ht
$result[10] = price2num(($tot_avec_remise_withoutvat * (1 + ($localtax2_rate / 100))) - $tot_avec_remise_withoutvat, 'MT'); // amount tax2 for total_ht
$result[2] += $result[10]; // total_ttc + tax2
$result[12] = price2num(($pu * (1 + ($localtax2_rate / 100))) - $pu, 'MU'); // amount tax2 for pu_ht
$result[12] = price2num(($pu_withouttax * (1 + ($localtax2_rate / 100))) - $pu_withouttax, 'MU'); // amount tax2 for pu_ht
$result[5] += $result[12]; // pu_ht + tax2
}