From 0ca6661e6916e06e38a2f5873a8d91e2363d8d31 Mon Sep 17 00:00:00 2001 From: Alexis Algoud Date: Sat, 7 Feb 2015 23:33:37 +0100 Subject: [PATCH] FIX empty discount where created if amount is null for a line with a different tva --- htdocs/compta/facture.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 8e74c674084..67ba28b4e47 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -563,10 +563,12 @@ if (empty($reshook)) // Boucle sur chaque taux de tva $i = 0; foreach ($object->lines as $line) { - $amount_ht [$line->tva_tx] += $line->total_ht; - $amount_tva [$line->tva_tx] += $line->total_tva; - $amount_ttc [$line->tva_tx] += $line->total_ttc; - $i ++; + if($line->total_ht!=0) { // no need to create discount if amount is null + $amount_ht [$line->tva_tx] += $line->total_ht; + $amount_tva [$line->tva_tx] += $line->total_tva; + $amount_ttc [$line->tva_tx] += $line->total_ttc; + $i ++; + } } // Insert one discount by VAT rate category @@ -583,6 +585,7 @@ if (empty($reshook)) $discount->fk_facture_source = $object->id; $error = 0; + foreach ($amount_ht as $tva_tx => $xxx) { $discount->amount_ht = abs($amount_ht [$tva_tx]); $discount->amount_tva = abs($amount_tva [$tva_tx]);