From ec87bfcb7e9a7cfd989f848b9fce7f3064a5cc15 Mon Sep 17 00:00:00 2001 From: Andre Cianfarani Date: Tue, 21 Feb 2006 12:49:48 +0000 Subject: [PATCH] modif pour assujetis tva ou pas --- htdocs/commande/commande.class.php | 31 ++++++++++++++++++------------ htdocs/commande/fiche.php | 11 +++++++++-- 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/htdocs/commande/commande.class.php b/htdocs/commande/commande.class.php index 004a375130e..0a4c8ee9612 100644 --- a/htdocs/commande/commande.class.php +++ b/htdocs/commande/commande.class.php @@ -254,18 +254,23 @@ class Commande $prod = new Product($this->db, $this->products[$i]); if ($prod->fetch($this->products[$i])) { + $this->soc_id; + $client = new Societe($this->db); + $client->fetch($this->soc_id); + if($client->tva_assuj == "0") + $tva_tx ="0"; + else + $tva_tx=$prod->tva_tx; // multiprix if($conf->global->PRODUIT_MULTIPRICES == 1) { - $this->soc_id; - $client = new Societe($this->db); - $client->fetch($this->soc_id); + //$prod->multiprices[$client->price_level] $this->insert_product_generic($prod->libelle, $prod->description, $prod->multiprices[$client->price_level], $this->products_qty[$i], - $prod->tva_tx, + $tva_tx, $this->products[$i], $this->products_remise_percent[$i]); } @@ -275,7 +280,7 @@ class Commande $prod->description, $prod->price, $this->products_qty[$i], - $prod->tva_tx, + $tva_tx, $this->products[$i], $this->products_remise_percent[$i]); } @@ -409,20 +414,22 @@ class Commande { $desc = $desc?$desc:$prod->libelle; $product_desc = $prod->description; + $client = new Societe($this->db); + $client->fetch($this->soc_id); + if($client->tva_assuj == "0") + $txtva ="0"; + else + $txtva=$prod->tva_tx; // multiprix if($conf->global->PRODUIT_MULTIPRICES == 1) { - $client = new Societe($this->db); - $client->fetch($this->soc_id); $pu = $prod->multiprices[$client->price_level]; - } else $pu = $prod->price; - $txtva = $prod->tva_tx; + } } - $remise = 0; $price = round(ereg_replace(',','.',$pu), 2); $subprice = $price; @@ -489,8 +496,8 @@ class Commande } $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'commandedet (fk_commande,label,description,fk_product, price,qty,tva_tx, remise_percent, subprice, remise)'; - $sql .= " VALUES ($this->id, '" . addslashes($desc) . "','" . addslashes($desc) . "',$fk_product,".price2num($price).", '$qty', $txtva, $remise_percent,'".price2num($subprice)."','".price2num( $remise)."') ;"; - + $sql .= " VALUES ($this->id, '" . addslashes($desc) . "','" . addslashes($desc) . "','$fk_product',".price2num($price).", '$qty', '$txtva', $remise_percent,'".price2num($subprice)."','".price2num( $remise)."') ;"; + print $sql; if ( $this->db->query( $sql) ) { $this->update_price(); diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index f82d77afa38..5a35a6a8533 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -807,6 +807,7 @@ else print ''.stripslashes(nl2br($objp->description)); print ''; } + print ''.$objp->tva_tx.'%'; print ''.price($objp->subprice).''; print ''.$objp->qty.''; @@ -857,7 +858,10 @@ else } print ''; print ''; - print $html->select_tva('eltva_tx',$objp->tva_tx,$mysoc,$soc); + if($soc->tva_assuj == "0") + print '0'; + else + print $html->select_tva('eltva_tx',$objp->tva_tx,$mysoc,$soc); print ''; print ''; print ''; @@ -903,7 +907,10 @@ else print ''; print ' '; print ''; - print $html->select_tva('tva_tx',$conf->defaulttx,$mysoc,$soc); + if($soc->tva_assuj == "0") + print '0'; + else + print $html->select_tva('tva_tx',$conf->defaulttx,$mysoc,$soc); print ''; print ''; print '';