From 7f90fe72950f937827dfd23cd0d3405ae0abe852 Mon Sep 17 00:00:00 2001 From: Rodolphe Quiedeville Date: Mon, 19 Jul 2004 08:58:07 +0000 Subject: [PATCH] Modif calcul TVA --- htdocs/facturefourn.class.php | 51 ++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/htdocs/facturefourn.class.php b/htdocs/facturefourn.class.php index 1560c892da6..e45598fab68 100644 --- a/htdocs/facturefourn.class.php +++ b/htdocs/facturefourn.class.php @@ -301,31 +301,31 @@ class FactureFourn */ Function updateline($id, $label, $puht, $tauxtva, $qty=1) { - $puht = ereg_replace(",",".",$puht); - - $totalht = $puht * $qty; - $tva = ($totalht * $tauxtva / 100); - $totalttc = $totalht + $tva; - - - $sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_det "; - $sql .= "SET description ='".$label."'"; - $sql .= ", pu_ht = '$puht'"; - $sql .= ", qty ='$qty'"; - $sql .= ", total_ht='$totalht'"; - $sql .= ", tva='$tva'"; - $sql .= ", tva_taux='$tauxtva'"; - $sql .= ", total_ttc='$totalttc'"; - - $sql .= " WHERE rowid = $id"; - - if (! $this->db->query($sql) ) + if (is_numeric($puht) && is_numeric($qty)) { - print $this->db->error() . '
'.$sql; + $totalht = ($puht * $qty); + $tva = ($totalht * $tauxtva / 100); + $totalttc = $totalht + $tva; + + $sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_det "; + $sql .= "SET description ='".$label."'"; + $sql .= ", pu_ht = " .ereg_replace(",",".",$puht); + $sql .= ", qty =" .ereg_replace(",",".",$qty); + $sql .= ", total_ht=" .ereg_replace(",",".",$totalht); + $sql .= ", tva=" .ereg_replace(",",".",$tva); + $sql .= ", tva_taux=" .ereg_replace(",",".",$tauxtva); + $sql .= ", total_ttc=".ereg_replace(",",".",$totalttc); + + $sql .= " WHERE rowid = $id"; + + if (! $this->db->query($sql) ) + { + print $this->db->error() . '
'.$sql; + } + + // Mise a jour prix facture + $this->updateprice($this->id); } - - // Mise a jour prix facture - $this->updateprice($this->id); } /** * Supprime une ligne de la facture @@ -382,7 +382,10 @@ class FactureFourn } - $sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn SET total_ht = '$total_ht', total_tva = '$total_tva', total_ttc = '$total_ttc'"; + $sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn SET"; + $sql .= " total_ht = ". ereg_replace(",",".",$total_ht); + $sql .= ",total_tva = ".ereg_replace(",",".",$total_tva); + $sql .= ",total_ttc = ".ereg_replace(",",".",$total_ttc); $sql .= " WHERE rowid = $facid ;"; $result = $this->db->query($sql);