From 58cb73e17b7bf630894ff1963b42453109f4956e Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Wed, 3 Dec 2014 22:53:54 +0100 Subject: [PATCH] Task #1064 - VEN si autoliquidation montant incorrect remove commented code --- html/compute.php | 3 ++- include/class_acc_ledger_purchase.php | 4 ++-- include/class_acc_ledger_sold.php | 7 ++++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/html/compute.php b/html/compute.php index 1ad8c2eda..d49d484ed 100644 --- a/html/compute.php +++ b/html/compute.php @@ -73,7 +73,8 @@ if ( $t != -1 && isNumber($t) == 1 ) { $total->set_parameter('amount_vat_rate',$tva_rate->get_parameter('rate')); $total->compute_vat(); - $tvac=bcadd($total->get_parameter('amount_vat'),$amount); + if ($tva_rate->get_parameter('both_side')== 1) $total->set_parameter('amount_vat', 0); + $tvac=($tva_rate->get_parameter('rate') == 0 || $tva_rate->get_parameter('both_side')== 1) ? $amount : bcadd($total->get_parameter('amount_vat'),$amount); header("Content-type: text/html; charset: utf8",true); echo '{"ctl":"'.$n.'","htva":"'.$amount.'","tva":"'.$total->get_parameter('amount_vat').'","tvac":"'.$tvac.'"}'; } diff --git a/include/class_acc_ledger_purchase.php b/include/class_acc_ledger_purchase.php index c796ea6b5..bff7555d8 100644 --- a/include/class_acc_ledger_purchase.php +++ b/include/class_acc_ledger_purchase.php @@ -569,7 +569,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger if ( $g_parameter->MY_TVA_USE=='Y') { $acc_amount->set_parameter('amount_vat_rate',$oTva->get_parameter('rate')); - if ( strlen(trim(${'e_march'.$i.'_tva_amount'})) ==0) + if ( strlen(trim(${'e_march'.$i.'_tva_amount'})) ==0 || ${'e_march'.$i.'_tva_amount'} == 0) { $acc_amount->compute_vat(); @@ -1489,7 +1489,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger same */ bcscale(2); $css_void_tva=($both_side == 1)?'style="text-decoration:line-through"':''; - if ( bcsub($tva_item,$tva_computed) != 0) + if ( bcsub($tva_item,$tva_computed) != 0 && ! ($tva_item == 0 && $both_side == 1)) { $r.=''; diff --git a/include/class_acc_ledger_sold.php b/include/class_acc_ledger_sold.php index f7263a05a..b40bc03cb 100644 --- a/include/class_acc_ledger_sold.php +++ b/include/class_acc_ledger_sold.php @@ -315,7 +315,7 @@ class Acc_Ledger_Sold extends Acc_Ledger { $oTva->set_parameter("id", $idx_tva); $oTva->load(); /* if empty then we need to compute it */ - if (trim($tva_item) == '') { + if (trim($tva_item) == '' || ${'e_march'.$i.'_tva_amount'} == 0) { /* retrieve tva */ $l = new Acc_Tva($this->db, $idx_tva); $l->load(); @@ -753,14 +753,15 @@ class Acc_Ledger_Sold extends Acc_Ledger { $r.=''; $r.=nbm(${"e_quant" . $i}); $r.=''; + $both_side=0; if ($g_parameter->MY_TVA_USE == 'Y') { $r.=''; $r.=$oTva->get_parameter('label'); $r.=''; - + $both_side=$oTva->get_parameter("both_side"); /* warning if tva_computed and given are not the same */ - if (bcsub($tva_item, $tva_computed) != 0) { + if (bcsub($tva_item, $tva_computed) != 0 && ! ($tva_item == 0 && $both_side == 1)) { $r.=''; $r.=HtmlInput::infobulle(28); $r.=''