From 17f37cc9e1d9f879e667991c011aded6bdab45c4 Mon Sep 17 00:00:00 2001 From: phf Date: Thu, 11 May 2017 11:41:00 +0200 Subject: [PATCH 1/2] Fix wrong calculation --- htdocs/compta/facture/card.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 9483e79dba4..06b64d02da6 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -1084,6 +1084,7 @@ if (empty($reshook)) } if ($totalamount != 0) { + $i = $i > 0 ? $i-1 : 0; $tva_tx = $lines[$i]->tva_tx; if (! empty($lines[$i]->vat_src_code) && ! preg_match('/\(/', $tva_tx)) $tva_tx .= ' ('.$lines[$i]->vat_src_code.')'; $amountdeposit[$tva_tx] = ($totalamount * $valuedeposit) / 100; @@ -1134,7 +1135,7 @@ if (empty($reshook)) if (!empty($conf->global->MAIN_DEPOSIT_MULTI_TVA) && $diff != 0) { $object->fetch_lines(); - $subprice_diff = $object->lines[0]->subprice - $diff / (1 + $object->lines[0]->tva_tx); + $subprice_diff = $object->lines[0]->subprice - $diff / (1 + $object->lines[0]->tva_tx / 100); $object->updateline($object->lines[0]->id, $object->lines[0]->desc, $subprice_diff, $object->lines[0]->qty, $object->lines[0]->remise_percent, $object->lines[0]->date_start, $object->lines[0]->date_end, $object->lines[0]->tva_tx, 0, 0, 'HT', $object->lines[0]->info_bits, $object->lines[0]->product_type, 0, 0, 0, $object->lines[0]->pa_ht, $object->lines[0]->label, 0, array(), 100); } From d120a391f9ac4f6b617e7d95883647d1657021dd Mon Sep 17 00:00:00 2001 From: phf Date: Mon, 15 May 2017 10:26:40 +0200 Subject: [PATCH 2/2] Fix use $numlines instead $i --- htdocs/compta/facture/card.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 06b64d02da6..91f64dc8693 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -1084,9 +1084,9 @@ if (empty($reshook)) } if ($totalamount != 0) { - $i = $i > 0 ? $i-1 : 0; - $tva_tx = $lines[$i]->tva_tx; - if (! empty($lines[$i]->vat_src_code) && ! preg_match('/\(/', $tva_tx)) $tva_tx .= ' ('.$lines[$i]->vat_src_code.')'; + if ($numlines > 0) $numlines = $numlines-1; + $tva_tx = $lines[$numlines]->tva_tx; + if (! empty($lines[$numlines]->vat_src_code) && ! preg_match('/\(/', $tva_tx)) $tva_tx .= ' ('.$lines[$numlines]->vat_src_code.')'; $amountdeposit[$tva_tx] = ($totalamount * $valuedeposit) / 100; } else { $amountdeposit[0] = 0;