Correction calcul tva
This commit is contained in:
parent
8f91bf1aa2
commit
4fe0510f50
@ -336,27 +336,38 @@ class Facture
|
|||||||
Function updateprice($facid)
|
Function updateprice($facid)
|
||||||
{
|
{
|
||||||
|
|
||||||
$sql = "SELECT sum(price*qty) FROM llx_facturedet WHERE fk_facture = $facid;";
|
$sql = "SELECT price, qty, tva_taux FROM llx_facturedet WHERE fk_facture = $facid;";
|
||||||
|
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
|
|
||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
if ($this->db->num_rows() )
|
$num = $this->db->num_rows();
|
||||||
|
$i = 0;
|
||||||
|
$totalht = 0;
|
||||||
|
$totaltva = 0;
|
||||||
|
while ($i < $num)
|
||||||
{
|
{
|
||||||
$row = $this->db->fetch_row();
|
$obj = $this->db->fetch_object($i);
|
||||||
$totalht = $row[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
$tva = tva($totalht);
|
$totalht = $totalht + ($obj->qty * $obj->price);
|
||||||
$total = $totalht + $tva;
|
$totaltva = $totaltva + tva($obj->qty * $obj->price, $obj->tva_taux);
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
$this->db->free();
|
||||||
|
|
||||||
|
$total = $totalht + $totaltva;
|
||||||
|
|
||||||
$sql = "UPDATE llx_facture SET amount = $totalht, tva=$tva, total=$total";
|
$sql = "UPDATE llx_facture SET amount = $totalht, tva=$totaltva, total=$total";
|
||||||
$sql .= " WHERE rowid = $facid ;";
|
$sql .= " WHERE rowid = $facid ;";
|
||||||
|
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print "Error";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -365,16 +376,8 @@ class Facture
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
Function pdf()
|
Function pdf()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
print "<hr><b>Génération du PDF</b><p>";
|
|
||||||
|
|
||||||
$command = "export DBI_DSN=\"".$GLOBALS["DBI"]."\" ";
|
|
||||||
$command .= " ; ../../scripts/facture-tex.pl --facture=$facid --pdf --ps" ;
|
|
||||||
|
|
||||||
$output = system($command);
|
|
||||||
print "<p>command : $command<br>";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user