Merge pull request #10800 from atm-quentin/FIX_wrong_vat_deposit_invoice
Wrong vat if deposit from propal with multiple vat
This commit is contained in:
commit
89087c6847
@ -1196,15 +1196,15 @@ if (empty($reshook))
|
|||||||
$qualified=1;
|
$qualified=1;
|
||||||
if (empty($lines[$i]->qty)) $qualified=0; // We discard qty=0, it is an option
|
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 (! 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($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 {
|
|
||||||
$amountdeposit[0] = 0;
|
$amountdeposit[0] = 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -1215,7 +1215,6 @@ if (empty($reshook))
|
|||||||
|
|
||||||
$amount_ttc_diff = $amountdeposit[0];
|
$amount_ttc_diff = $amountdeposit[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($amountdeposit as $tva => $amount)
|
foreach ($amountdeposit as $tva => $amount)
|
||||||
{
|
{
|
||||||
if (empty($amount)) continue;
|
if (empty($amount)) continue;
|
||||||
@ -1228,6 +1227,7 @@ if (empty($reshook))
|
|||||||
} elseif ($typeamount=='variable') {
|
} elseif ($typeamount=='variable') {
|
||||||
$descline.= ' ('. $valuedeposit.'%)';
|
$descline.= ' ('. $valuedeposit.'%)';
|
||||||
}
|
}
|
||||||
|
|
||||||
$descline.= ' - '.$srcobject->ref;
|
$descline.= ' - '.$srcobject->ref;
|
||||||
$result = $object->addline(
|
$result = $object->addline(
|
||||||
$descline,
|
$descline,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user