diff --git a/htdocs/comm/remx.php b/htdocs/comm/remx.php index fb6f6c0e24a..d836864b7bb 100644 --- a/htdocs/comm/remx.php +++ b/htdocs/comm/remx.php @@ -21,7 +21,7 @@ * \file htdocs/comm/remx.php * \ingroup societe * \brief Page to edit absolute discounts for a customer - * \version $Id: remx.php,v 1.52 2011/08/03 00:46:26 eldy Exp $ + * \version $Id: remx.php,v 1.53 2011/08/04 21:46:51 eldy Exp $ */ require("../main.inc.php"); @@ -270,7 +270,7 @@ if ($_socid > 0) print ' '.$langs->trans("Currency".$conf->monnaie).''; print ''.$langs->trans("VAT").''; print ''; - $form->select_tva('tva_tx','0','',$mysoc,''); + print $form->load_tva('tva_tx','0','',$mysoc,''); print ''; print ''.$langs->trans("NoteReason").''; print ''; @@ -538,5 +538,5 @@ if ($_socid > 0) $db->close(); -llxFooter('$Date: 2011/08/03 00:46:26 $ - $Revision: 1.52 $'); +llxFooter('$Date: 2011/08/04 21:46:51 $ - $Revision: 1.53 $'); ?> diff --git a/htdocs/contrat/fiche.php b/htdocs/contrat/fiche.php index b0145e14628..86c21b1378b 100644 --- a/htdocs/contrat/fiche.php +++ b/htdocs/contrat/fiche.php @@ -23,7 +23,7 @@ * \file htdocs/contrat/fiche.php * \ingroup contrat * \brief Page of a contract - * \version $Id: fiche.php,v 1.198 2011/08/02 12:44:20 simnandez Exp $ + * \version $Id: fiche.php,v 1.199 2011/08/04 21:46:51 eldy Exp $ */ require ("../main.inc.php"); @@ -875,7 +875,7 @@ else } print ''; print ''; - print $form->select_tva("eltva_tx",$objp->tva_tx,$mysoc,$object->societe); + print $form->load_tva("eltva_tx",$objp->tva_tx,$mysoc,$object->societe); print ''; print ''; print ''; @@ -1195,7 +1195,7 @@ else print ''; print ''; - $form->select_tva("tva_tx",$conf->defaulttx,$mysoc,$object->societe); + print $form->load_tva("tva_tx",-1,$mysoc,$object->societe); print ''; print ''; print ''; @@ -1286,5 +1286,5 @@ else $db->close(); -llxFooter('$Date: 2011/08/02 12:44:20 $ - $Revision: 1.198 $'); +llxFooter('$Date: 2011/08/04 21:46:51 $ - $Revision: 1.199 $'); ?> diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index c5664164e74..8f0280a959a 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -24,7 +24,7 @@ * \ingroup core * \brief File of class to manage storage of current setup * Config is stored into file conf.php - * \version $Id: conf.class.php,v 1.64 2011/08/01 13:26:22 hregis Exp $ + * \version $Id: conf.class.php,v 1.65 2011/08/04 21:46:51 eldy Exp $ */ @@ -325,15 +325,6 @@ class Conf $this->compta->mode = 'RECETTES-DEPENSES'; // By default if (isset($this->global->COMPTA_MODE)) $this->compta->mode = $this->global->COMPTA_MODE; // Can be 'RECETTES-DEPENSES' ou 'CREANCES-DETTES' - // $this->defaulttx - if (isset($this->global->FACTURE_TVAOPTION) && $this->global->FACTURE_TVAOPTION == 'franchise') - { - $this->defaulttx='0'; // Taux par defaut des factures clients - } - else { - $this->defaulttx=''; // Pas de taux par defaut des factures clients, le plus élevé sera pris - } - // $this->liste_limit = constante de taille maximale des listes if (empty($this->global->MAIN_SIZE_LISTE_LIMIT)) $this->global->MAIN_SIZE_LISTE_LIMIT=25; $this->liste_limit=$this->global->MAIN_SIZE_LISTE_LIMIT; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index e24b3c7c717..d56dc9d2f51 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -30,7 +30,7 @@ * \file htdocs/core/class/html.form.class.php * \ingroup core * \brief File of class with all html predefined components - * \version $Id: html.form.class.php,v 1.193 2011/07/31 23:45:14 eldy Exp $ + * \version $Id: html.form.class.php,v 1.194 2011/08/04 21:46:51 eldy Exp $ */ @@ -2669,11 +2669,10 @@ class Form * Si (vendeur et acheteur dans Communaute europeenne) et bien vendu = moyen de transports neuf (auto, bateau, avion), TVA par defaut=0 (La TVA doit etre paye par l'acheteur au centre d'impots de son pays et non au vendeur). Fin de regle. * Si (vendeur et acheteur dans Communaute europeenne) et bien vendu autre que transport neuf alors la TVA par defaut=TVA du produit vendu. Fin de regle. * Sinon la TVA proposee par defaut=0. Fin de regle. + * @deprecated */ function select_tva($htmlname='tauxtva', $selectedrate='', $societe_vendeuse='', $societe_acheteuse='', $idprod=0, $info_bits=0, $type='') { - // TODO size of field is too large - //print ''; print $this->load_tva($htmlname, $selectedrate, $societe_vendeuse, $societe_acheteuse, $idprod, $info_bits, $type); } @@ -2800,6 +2799,7 @@ class Form $defaulttx=get_default_tva($societe_vendeuse,$societe_acheteuse,$idprod); $defaultnpr=get_default_npr($societe_vendeuse,$societe_acheteuse,$idprod); } + // Si taux par defaut n'a pu etre determine, on prend dernier de la liste. // Comme ils sont tries par ordre croissant, dernier = plus eleve = taux courant if ($defaulttx < 0 || dol_strlen($defaulttx) == 0) diff --git a/htdocs/core/tpl/freeproductline_create.tpl.php b/htdocs/core/tpl/freeproductline_create.tpl.php index 2347cf47f92..a9f84fe4ee1 100644 --- a/htdocs/core/tpl/freeproductline_create.tpl.php +++ b/htdocs/core/tpl/freeproductline_create.tpl.php @@ -15,7 +15,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . * - * $Id: freeproductline_create.tpl.php,v 1.15 2011/07/31 23:45:13 eldy Exp $ + * $Id: freeproductline_create.tpl.php,v 1.16 2011/08/04 21:46:50 eldy Exp $ * * Need to have following variables defined: * $conf @@ -46,7 +46,7 @@ select_type_of_lines(isset($_POST["type"])?$_POST["type"]:-1,'type',1); if (($conf->product->enabled && $conf->service->enabled) || (empty($conf->product->enabled) && empty($conf->service->enabled))) echo '
'; - + if (! empty($this->hooks)) { foreach($this->hooks as $hook) { if (! empty($hook['modules'])) { @@ -59,7 +59,7 @@ } } } - + // Editor wysiwyg require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); $nbrows=ROWS_2; @@ -72,7 +72,7 @@ tva_assuj == "0") echo '0'; - else $html->select_tva('np_tva_tx', $conf->defaulttx, $seller, $buyer); + else echo $html->load_tva('np_tva_tx', -1, $seller, $buyer); ?> diff --git a/htdocs/core/tpl/freeproductline_edit.tpl.php b/htdocs/core/tpl/freeproductline_edit.tpl.php index 4eb6b873070..701d5c2c52d 100644 --- a/htdocs/core/tpl/freeproductline_edit.tpl.php +++ b/htdocs/core/tpl/freeproductline_edit.tpl.php @@ -15,7 +15,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . * - * $Id: freeproductline_edit.tpl.php,v 1.15 2011/07/31 23:45:11 eldy Exp $ + * $Id: freeproductline_edit.tpl.php,v 1.16 2011/08/04 21:46:50 eldy Exp $ * * Need to have following variables defined: * $conf @@ -37,7 +37,7 @@ > - + hooks)) { foreach($this->hooks as $hook) { @@ -61,7 +61,7 @@ ?> - select_tva('tva_tx',$line->tva_tx,$seller,$buyer,0,$line->info_bits,$line->product_type); ?> + load_tva('tva_tx',$line->tva_tx,$seller,$buyer,0,$line->info_bits,$line->product_type); ?> diff --git a/htdocs/core/tpl/predefinedproductline_edit.tpl.php b/htdocs/core/tpl/predefinedproductline_edit.tpl.php index 16f9813339c..09b7d7dd81e 100644 --- a/htdocs/core/tpl/predefinedproductline_edit.tpl.php +++ b/htdocs/core/tpl/predefinedproductline_edit.tpl.php @@ -15,7 +15,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . * - * $Id: predefinedproductline_edit.tpl.php,v 1.14 2011/07/31 23:45:11 eldy Exp $ + * $Id: predefinedproductline_edit.tpl.php,v 1.15 2011/08/04 21:46:50 eldy Exp $ * * Need to have following variables defined: * $conf @@ -69,7 +69,7 @@ ?> - select_tva('tva_tx',$line->tva_tx,$seller,$buyer,'',$line->info_bits); ?> + load_tva('tva_tx',$line->tva_tx,$seller,$buyer,'',$line->info_bits); ?> diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php index b977bfe42a1..cd489412845 100644 --- a/htdocs/fourn/commande/fiche.php +++ b/htdocs/fourn/commande/fiche.php @@ -25,7 +25,7 @@ * \file htdocs/fourn/commande/fiche.php * \ingroup supplier, order * \brief Card supplier order - * \version $Id: fiche.php,v 1.232 2011/07/10 20:03:40 eldy Exp $ + * \version $Id: fiche.php,v 1.233 2011/08/04 21:46:51 eldy Exp $ */ require("../../main.inc.php"); @@ -1174,7 +1174,7 @@ if ($id > 0 || ! empty($ref)) print ''; print ''; - $html->select_tva('tva_tx',$line->tva_tx); + print $html->load_tva('tva_tx',$line->tva_tx); print ''; print ''; print ''; @@ -1227,10 +1227,7 @@ if ($id > 0 || ! empty($ref)) print ''; print ''; - //if($soc->tva_assuj == "0") - //print '0'; - //else - print $html->select_tva('tva_tx',($_POST["tva_tx"]?$_POST["tva_tx"]:$conf->defaulttx),$soc,$mysoc); + print $html->load_tva('tva_tx',($_POST["tva_tx"]?$_POST["tva_tx"]:-1),$soc,$mysoc); print ''; print ''; print ''; @@ -1545,5 +1542,5 @@ if ($id > 0 || ! empty($ref)) $db->close(); -llxFooter('$Date: 2011/07/10 20:03:40 $ - $Revision: 1.232 $'); +llxFooter('$Date: 2011/08/04 21:46:51 $ - $Revision: 1.233 $'); ?> diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php index 2997c99350a..b6453dbba2d 100644 --- a/htdocs/fourn/facture/fiche.php +++ b/htdocs/fourn/facture/fiche.php @@ -24,7 +24,7 @@ * \file htdocs/fourn/facture/fiche.php * \ingroup facture, fournisseur * \brief Page for supplier invoice card (view, edit, validate) - * \version $Id: fiche.php,v 1.262 2011/07/31 23:57:00 eldy Exp $ + * \version $Id: fiche.php,v 1.263 2011/08/04 21:46:50 eldy Exp $ */ require("../../main.inc.php"); @@ -1114,7 +1114,7 @@ if ($_GET['action'] == 'create') print ''; print ''; print ''; - $html->select_tva('tauxtva'.$i,$value_tauxtva,$societe,$mysoc); + print $html->load_tva('tauxtva'.$i,$value_tauxtva,$societe,$mysoc); print ''; print ''; print ''; @@ -1549,7 +1549,7 @@ else // VAT print ''; - $html->select_tva('tauxtva',$fac->lines[$i]->tva_tx,$societe,$mysoc); + print $html->load_tva('tauxtva',$fac->lines[$i]->tva_tx,$societe,$mysoc); print ''; // Unit price @@ -1678,7 +1678,7 @@ else print ''; print ''; - print $html->select_tva('tauxtva',$conf->defaulttx,$societe,$mysoc); + print $html->load_tva('tauxtva',($_POST["tauxtva"]?$_POST["tauxtva"]:-1),$societe,$mysoc); print ''; print ''; print ''; @@ -1915,5 +1915,5 @@ else $db->close(); -llxFooter('$Date: 2011/07/31 23:57:00 $ - $Revision: 1.262 $'); +llxFooter('$Date: 2011/08/04 21:46:50 $ - $Revision: 1.263 $'); ?> diff --git a/htdocs/lib/functions.lib.php b/htdocs/lib/functions.lib.php index fa07d64073b..7ad52faee6b 100644 --- a/htdocs/lib/functions.lib.php +++ b/htdocs/lib/functions.lib.php @@ -28,7 +28,7 @@ * \file htdocs/lib/functions.lib.php * \brief A set of functions for Dolibarr * This file contains all frequently used functions. - * \version $Id: functions.lib.php,v 1.550 2011/08/04 07:50:25 hregis Exp $ + * \version $Id: functions.lib.php,v 1.551 2011/08/04 21:46:50 eldy Exp $ */ // For compatibility during upgrade @@ -3150,14 +3150,24 @@ function get_default_tva($societe_vendeuse, $societe_acheteuse, $idprod=0) dol_syslog("get_default_tva: seller use vat=".$societe_vendeuse->tva_assuj.", seller country=".$societe_vendeuse->pays_code.", seller in cee=".$societe_vendeuse->isInEEC().", buyer country=".$societe_acheteuse->pays_code.", buyer in cee=".$societe_acheteuse->isInEEC().", idprod=".$idprod.", SERVICE_ARE_ECOMMERCE_200238EC=".$conf->global->SERVICES_ARE_ECOMMERCE_200238EC); // Si vendeur non assujeti a TVA (tva_assuj vaut 0/1 ou franchise/reel) - if (is_numeric($societe_vendeuse->tva_assuj) && ! $societe_vendeuse->tva_assuj) return 0; - if (! is_numeric($societe_vendeuse->tva_assuj) && $societe_vendeuse->tva_assuj=='franchise') return 0; + if (is_numeric($societe_vendeuse->tva_assuj) && ! $societe_vendeuse->tva_assuj) + { + //print 'VATRULE 1'; + return 0; + } + if (! is_numeric($societe_vendeuse->tva_assuj) && $societe_vendeuse->tva_assuj=='franchise') + { + //print 'VATRULE 2'; + return 0; + } - // Si le (pays vendeur = pays acheteur) alors la TVA par defaut=TVA du produit vendu. Fin de regle. //if (is_object($societe_acheteuse) && ($societe_vendeuse->pays_id == $societe_acheteuse->pays_id) && ($societe_acheteuse->tva_assuj == 1 || $societe_acheteuse->tva_assuj == 'reel')) // Le test ci-dessus ne devrait pas etre necessaire. Me signaler l'exemple du cas juridique concerne si le test suivant n'est pas suffisant. - if ($societe_vendeuse->pays_code == $societe_acheteuse->pays_code) // Warning ->pays_id not always defined + + // Si le (pays vendeur = pays acheteur) alors la TVA par defaut=TVA du produit vendu. Fin de regle. + if ($societe_vendeuse->pays_code == $societe_acheteuse->pays_code) // Warning ->pays_code not always defined { + //print 'VATRULE 3'; return get_product_vat_for_country($idprod,$societe_vendeuse->pays_code); } @@ -3171,10 +3181,12 @@ function get_default_tva($societe_vendeuse, $societe_acheteuse, $idprod=0) $isacompany=$societe_acheteuse->isACompany(); if ($isacompany) { + //print 'VATRULE 4'; return 0; } else { + //print 'VATRULE 5'; return get_product_vat_for_country($idprod,$societe_vendeuse->pays_code); } } @@ -3186,12 +3198,14 @@ function get_default_tva($societe_vendeuse, $societe_acheteuse, $idprod=0) //print "eee".$societe_acheteuse->isACompany();exit; if (! $societe_vendeuse->isInEEC() && $societe_acheteuse->isInEEC() && ! $societe_acheteuse->isACompany()) { + //print 'VATRULE 6'; return get_product_vat_for_country($idprod,$societe_acheteuse->pays_code); } } // Sinon la TVA proposee par defaut=0. Fin de regle. // Rem: Cela signifie qu'au moins un des 2 est hors Communaute europeenne et que le pays differe + //print 'VATRULE 7'; return 0; } diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 8bccf934120..de7eb9ed069 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -24,7 +24,7 @@ * \file htdocs/product/class/product.class.php * \ingroup produit * \brief Fichier de la classe des produits predefinis - * \version $Id: product.class.php,v 1.48 2011/07/31 23:24:03 eldy Exp $ + * \version $Id: product.class.php,v 1.49 2011/08/04 21:46:51 eldy Exp $ */ require_once(DOL_DOCUMENT_ROOT ."/core/class/commonobject.class.php"); @@ -2861,7 +2861,7 @@ class Product extends CommonObject $this->tpl['price_base_type'] = $html->load_PriceBaseType($this->price_base_type, "price_base_type"); // VAT - $this->tpl['tva_tx'] = $html->load_tva("tva_tx",$conf->defaulttx,$mysoc,''); + $this->tpl['tva_tx'] = $html->load_tva("tva_tx",-1,$mysoc,''); } if ($action == 'create' || $action == 'edit') diff --git a/htdocs/product/fiche.php b/htdocs/product/fiche.php index efbd289cb3f..c0b9dfabb70 100644 --- a/htdocs/product/fiche.php +++ b/htdocs/product/fiche.php @@ -25,7 +25,7 @@ * \file htdocs/product/fiche.php * \ingroup product * \brief Page to show product - * \version $Id: fiche.php,v 1.374 2011/07/31 23:19:26 eldy Exp $ + * \version $Id: fiche.php,v 1.375 2011/08/04 21:46:50 eldy Exp $ */ require("../main.inc.php"); @@ -793,7 +793,7 @@ if ($action == 'create' && ($user->rights->produit->creer || $user->rights->serv // VAT print ''.$langs->trans("VATRate").''; - print $html->select_tva("tva_tx",$conf->defaulttx,$mysoc,''); + print $html->load_tva("tva_tx",-1,$mysoc,''); print ''; print ''; @@ -1645,6 +1645,6 @@ if ($product->id && $action == '' && $product->status) $db->close(); -llxFooter('$Date: 2011/07/31 23:19:26 $ - $Revision: 1.374 $'); +llxFooter('$Date: 2011/08/04 21:46:50 $ - $Revision: 1.375 $'); ?> diff --git a/htdocs/product/price.php b/htdocs/product/price.php index 2ddb4aecbd2..a4cda019993 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -23,7 +23,7 @@ * \file htdocs/product/price.php * \ingroup product * \brief Page to show product prices - * \version $Id: price.php,v 1.110 2011/07/31 23:19:25 eldy Exp $ + * \version $Id: price.php,v 1.111 2011/08/04 21:46:50 eldy Exp $ */ require("../main.inc.php"); @@ -317,7 +317,7 @@ if ($_GET["action"] == 'edit_price' && ($user->rights->produit->creer || $user-> // VAT print ''.$langs->trans("VATRate").''; - print $html->select_tva("tva_tx",$product->tva_tx,$mysoc,'',$product->id); + print $html->load_tva("tva_tx",$product->tva_tx,$mysoc,'',$product->id); print ''; // Price base @@ -377,7 +377,7 @@ if ($_GET["action"] == 'edit_price' && ($user->rights->produit->creer || $user-> if ($i == 1) { print ''.$langs->trans("VATRate").''; - print $html->select_tva("tva_tx_".$i,$product->multiprices_tva_tx["$i"],$mysoc,'',$product->id); + print $html->load_tva("tva_tx_".$i,$product->multiprices_tva_tx["$i"],$mysoc,'',$product->id); print ''; } else @@ -534,5 +534,5 @@ else $db->close(); -llxFooter('$Date: 2011/07/31 23:19:25 $ - $Revision: 1.110 $'); +llxFooter('$Date: 2011/08/04 21:46:50 $ - $Revision: 1.111 $'); ?>