diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index b379bf31602..0f6820e1859 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -1196,15 +1196,15 @@ if (empty($reshook)) $qualified=1; if (empty($lines[$i]->qty)) $qualified=0; // We discard qty=0, it is an option if (! empty($lines[$i]->special_code)) $qualified=0; // We discard special_code (frais port, ecotaxe, option, ...) - if ($qualified) $totalamount += $lines[$i]->total_ht; // Fixme : is it not for the customer ? Shouldn't we take total_ttc ? + if ($qualified){ + $totalamount += $lines[$i]->total_ht; // Fixme : is it not for the customer ? Shouldn't we take total_ttc ? + $tva_tx = $lines[$i]->tva_tx; + $amountdeposit[$tva_tx] += ($lines[$i]->total_ht * $valuedeposit) / 100; + } + } - if ($totalamount != 0) { - 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 { + if($totalamount == 0) { $amountdeposit[0] = 0; } } else { @@ -1215,7 +1215,6 @@ if (empty($reshook)) $amount_ttc_diff = $amountdeposit[0]; } - foreach ($amountdeposit as $tva => $amount) { $arraylist = array('amount' => 'FixAmount','variable' => 'VarAmount'); @@ -1226,6 +1225,7 @@ if (empty($reshook)) } elseif ($typeamount=='variable') { $descline.= ' ('. $valuedeposit.'%)'; } + $descline.= ' - '.$srcobject->ref; $result = $object->addline( $descline,