From 71acc25736751f2f42261e5e5b0b9ebf26c3c9ec Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 19 Aug 2005 22:32:32 +0000 Subject: [PATCH] New: Gestion des taux de tva en base dans llx_c_tva --- htdocs/admin/dict.php | 61 +++++++++++++++++++++++---------- htdocs/html.form.class.php | 41 ++++++++++++++++------ htdocs/langs/en_US/admin.lang | 2 ++ htdocs/langs/en_US/main.lang | 1 + htdocs/langs/fr_FR/admin.lang | 2 ++ htdocs/langs/fr_FR/main.lang | 1 + mysql/data/data.sql | 13 +++++++ mysql/migration/1.1.0-2.0.0.sql | 23 +++++++++++++ 8 files changed, 115 insertions(+), 29 deletions(-) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 41d99512177..089533433ba 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -50,7 +50,7 @@ $active = 1; // Mettre ici tous les caractéristiques des dictionnaires // Ordres d'affichage des dictionnaires (0 pour espace) -$taborder=array(4,3,2,0,9,0,1,8,0,5,0,6,0,7); +$taborder=array(4,3,2,0,9,0,1,8,0,5,0,6,0,7,0,10); // Nom des tables des dictionnaires $tabname[1] = MAIN_DB_PREFIX."c_forme_juridique"; @@ -62,6 +62,7 @@ $tabname[6] = MAIN_DB_PREFIX."c_actioncomm"; $tabname[7] = MAIN_DB_PREFIX."c_chargesociales"; $tabname[8] = MAIN_DB_PREFIX."c_typent"; $tabname[9] = MAIN_DB_PREFIX."c_currencies"; +$tabname[10]= MAIN_DB_PREFIX."c_tva"; // Libellé des dictionnaires $tablib[1] = $langs->trans("DictionnaryCompanyJuridicalType"); @@ -73,6 +74,7 @@ $tablib[6] = $langs->trans("DictionnaryActions"); $tablib[7] = $langs->trans("DictionnarySocialContributions"); $tablib[8] = $langs->trans("DictionnaryCompanyType"); $tablib[9] = $langs->trans("DictionnaryCurrency"); +$tablib[10]= $langs->trans("DictionnaryVAT"); // Requete pour extraction des données des dictionnaires $tabsql[1] = "SELECT f.rowid as rowid, f.code, f.libelle, p.libelle as pays, f.active FROM llx_c_forme_juridique as f, llx_c_pays as p WHERE f.fk_pays=p.rowid"; @@ -84,17 +86,19 @@ $tabsql[6] = "SELECT a.id as rowid, a.code as code, a.libelle AS libelle, a.t $tabsql[7] = "SELECT a.id as rowid, a.id as code, a.libelle AS libelle, a.deductible, a.active FROM llx_c_chargesociales AS a"; $tabsql[8] = "SELECT id as rowid, code, libelle, active FROM llx_c_typent"; $tabsql[9] = "SELECT code as rowid, code, code_iso, label as libelle, active FROM llx_c_currencies"; +$tabsql[10]= "SELECT t.rowid, t.taux, p.libelle as pays, t.recuperableonly, t.note, t.active FROM llx_c_tva as t, llx_c_pays as p WHERE t.fk_pays=p.rowid"; // Tri par defaut -$tabsqlsort[1]="pays, code ASC"; -$tabsqlsort[2]="pays, code ASC"; -$tabsqlsort[3]="pays, code ASC"; -$tabsqlsort[4]="libelle ASC"; -$tabsqlsort[5]="libelle ASC"; -$tabsqlsort[6]="a.type ASC, a.code ASC"; -$tabsqlsort[7]="a.libelle ASC"; -$tabsqlsort[8]="libelle ASC"; -$tabsqlsort[9]="code ASC"; +$tabsqlsort[1] ="pays, code ASC"; +$tabsqlsort[2] ="pays, code ASC"; +$tabsqlsort[3] ="pays, code ASC"; +$tabsqlsort[4] ="libelle ASC"; +$tabsqlsort[5] ="libelle ASC"; +$tabsqlsort[6] ="a.type ASC, a.code ASC"; +$tabsqlsort[7] ="a.libelle ASC"; +$tabsqlsort[8] ="libelle ASC"; +$tabsqlsort[9] ="code ASC"; +$tabsqlsort[10]="pays ASC, taux ASC, recuperableonly ASC"; // Nom des champs en resultat de select pour affichage du dictionnaire $tabfield[1] = "code,libelle,pays"; @@ -106,6 +110,7 @@ $tabfield[6] = "code,libelle,type"; $tabfield[7] = "libelle,deductible"; $tabfield[8] = "code,libelle"; $tabfield[9] = "code,code_iso,libelle"; +$tabfield[10]= "pays,taux,recuperableonly,note"; // Nom des champs dans la table pour insertion d'un enregistrement $tabfieldinsert[1] = "code,libelle,fk_pays"; @@ -117,6 +122,7 @@ $tabfieldinsert[6] = "code,libelle,type"; $tabfieldinsert[7] = "libelle,deductible"; $tabfieldinsert[8] = "code,libelle"; $tabfieldinsert[9] = "code,code_iso,libelle"; +$tabfieldinsert[10]= "fk_pays,taux,recuperableonly,note"; // Nom du rowid si le champ n'est pas de type autoincrément $tabrowid[1] = ""; @@ -128,6 +134,7 @@ $tabrowid[6] = "id"; $tabrowid[7] = "id"; $tabrowid[8] = "id"; $tabrowid[9] = "code"; +$tabrowid[10]= ""; $msg=''; @@ -138,8 +145,8 @@ $sortfield=$_GET["sortfield"]; /* * Actions ajout d'une entrée dans un dictionnaire de donnée */ -if ($_POST["actionadd"]) { - +if ($_POST["actionadd"]) +{ $listfield=split(',',$tabfield[$_POST["id"]]); // Verifie que tous les champs sont renseignés @@ -205,6 +212,7 @@ if ($_POST["actionadd"]) { } } + if ($msg) $msg='
'.$msg.'
'; $_GET["id"]=$_POST["id"]; // Force affichage dictionnaire en cours d'edition } @@ -297,7 +305,9 @@ if ($_GET["id"]) // Ligne d'ajout if ($tabname[$_GET["id"]]) { + $alabelisused=0; $var=false; + $fieldlist=split(',',$tabfield[$_GET["id"]]); print ''; @@ -310,14 +320,17 @@ if ($_GET["id"]) // Determine le nom du champ par rapport aux noms possibles // dans les dictionnaires de données $valuetoshow=ucfirst($fieldlist[$field]); // Par defaut - if ($fieldlist[$field]=='lang') $valuetoshow=$langs->trans("Language"); - if ($fieldlist[$field]=='type') $valuetoshow=$langs->trans("Type"); - if ($fieldlist[$field]=='code') $valuetoshow=$langs->trans("Code"); - if ($fieldlist[$field]=='libelle') $valuetoshow=$langs->trans("Label")."*"; - if ($fieldlist[$field]=='pays') $valuetoshow=$langs->trans("Country"); + if ($fieldlist[$field]=='lang') $valuetoshow=$langs->trans("Language"); + if ($fieldlist[$field]=='type') $valuetoshow=$langs->trans("Type"); + if ($fieldlist[$field]=='code') $valuetoshow=$langs->trans("Code"); + if ($fieldlist[$field]=='libelle') $valuetoshow=$langs->trans("Label")."*"; + if ($fieldlist[$field]=='pays') $valuetoshow=$langs->trans("Country"); + if ($fieldlist[$field]=='recuperableonly') $valuetoshow=$langs->trans("VATReceivedOnly"); print ''; + + if ($fieldlist[$field]=='libelle') $alabelisused=1; } print ''; print ''; @@ -347,6 +360,11 @@ if ($_GET["id"]) print 'user'; print ''; } + elseif ($fieldlist[$field] == 'recuperableonly') { + print ''; + } else { print ''; } @@ -354,7 +372,10 @@ if ($_GET["id"]) print ''; print ""; - print ''; + if ($alabelisused) // Si un des champs est un libellé + { + print ''; + } print ''; print ''; @@ -379,6 +400,7 @@ if ($_GET["id"]) if ($fieldlist[$field]=='code') $valuetoshow=$langs->trans("Code"); if ($fieldlist[$field]=='libelle') $valuetoshow=$langs->trans("Label")."*"; if ($fieldlist[$field]=='pays') $valuetoshow=$langs->trans("Country"); + if ($fieldlist[$field]=='recuperableonly') $valuetoshow=$langs->trans("VATReceivedOnly"); // Affiche nom du champ print_liste_field_titre($valuetoshow,"dict.php",$fieldlist[$field],"&id=".$_GET["id"],"","",$sortfield); } @@ -399,6 +421,9 @@ if ($_GET["id"]) if ($valuetoshow=='all') { $valuetoshow=$langs->trans('All'); } + if ($fieldlist[$field]=='recuperableonly') { + $valuetoshow=yn($valuetoshow); + } print ''; } diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php index fa3ab2956d3..2c5a50137a5 100644 --- a/htdocs/html.form.class.php +++ b/htdocs/html.form.class.php @@ -884,40 +884,59 @@ class Form */ function select_tva($name='tauxtva', $defaulttx='', $default=0) { - global $langs; - - $file = DOL_DOCUMENT_ROOT . "/conf/tva.local.php"; - if (is_readable($file)) + global $langs,$conf; + + if (! $conf->global->MAIN_INFO_SOCIETE_PAYS) { - include $file; + print ''.$langs->trans("ErrorYourCountryIsNotDefined").''; + } + + $sql = "SELECT t.taux,t.recuperableonly"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_tva AS t"; + $sql .= " WHERE t.fk_pays = '".$conf->global->MAIN_INFO_SOCIETE_PAYS."'"; + $sql .= " AND t.active = 1"; + $sql .= " ORDER BY t.taux ASC, t.recuperableonly ASC"; + + if ($this->db->query($sql)) + { + $num = $this->db->num_rows(); + for ($i = 0; $i < $num; $i++) + { + $obj = $this->db->fetch_object(); + $txtva[ $i ] = $obj->taux; + $libtva[ $i ] = $obj->taux.'%'.($obj->recuperableonly ? ' *':''); + } } else { $txtva[0] = '19.6'; + $libtva[0] = ''; $txtva[1] = '5.5'; + $libtva[1] = ''; $txtva[2] = '0'; + $libtva[2] = ''; } - + if ($defaulttx == '') { $defaulttx = $txtva[0]; } - + $taille = sizeof($txtva); - + print ''; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 4190a5b5370..0c2754e1887 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -197,6 +197,8 @@ DictionnaryCurrency=Currencies DictionnaryCivility=Civility title DictionnaryActions=Actions list DictionnarySocialContributions=Social contributions types +DictionnaryVAT=VAT Rates +VATReceivedOnly=Special rate not billed LabelUsedByDefault=Label used by default if no translation can be found for code AlwaysActive=Always active UpdateRequired=Your system need to be updated. For this click on Update now. diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 355393c2891..69c2b57b7ab 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -18,6 +18,7 @@ ErrorFileNotUploaded=File was not uploaded ErrorInternalErrorDetected=Internal error detected ErrorNoRequestRan=No request ran ErrorWrongHostParameter=Wrong host parameter +ErrorYourCountryIsNotDefined=Your country is not defined. Go to Home-Setup-Edit and post again the form. HomeArea=Home area LastAccess=Last access RequestedUrl=Requested Url diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index ebbeb9f7fb5..ecd40d89d9d 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -197,6 +197,8 @@ DictionnaryCurrency=Monnaies DictionnaryCivility=Titres de civilité DictionnaryActions=Liste des actions DictionnarySocialContributions=Types de charges sociales +DictionnaryVAT=Taux de TVA +VATReceivedOnly=Taux special non facturé LabelUsedByDefault=Libellé qui sera utilisé si aucune traduction n'est trouvé pour ce code AlwaysActive=Toujours actif UpdateRequired=Votre système nécessite une mise à jour. Pour cela cliquez sur Mettre à jour. diff --git a/htdocs/langs/fr_FR/main.lang b/htdocs/langs/fr_FR/main.lang index 79465a030b6..708a5fce1bc 100644 --- a/htdocs/langs/fr_FR/main.lang +++ b/htdocs/langs/fr_FR/main.lang @@ -18,6 +18,7 @@ ErrorFileNotUploaded=Le fichier n'a pas ErrorInternalErrorDetected=Erreur interne détectée ErrorNoRequestRan=Aucune requête exécutée ErrorWrongHostParameter=Mauvais paramètre Serveur +ErrorYourCountryIsNotDefined=Votre pays n'est pas défini. Aller dans Configuration-Général-Editer et resoumettez le formulaire. HomeArea=Espace accueil LastAccess=Dernière connexion RequestedUrl=Url sollicitée diff --git a/mysql/data/data.sql b/mysql/data/data.sql index 64813fb6af9..0b01bba8e1c 100644 --- a/mysql/data/data.sql +++ b/mysql/data/data.sql @@ -686,3 +686,16 @@ insert into llx_c_currencies ( code, code_iso, active, label ) values ( 'LT', 'L insert into llx_c_currencies ( code, code_iso, active, label ) values ( 'RU', 'SUR', 1, 'Rouble'); insert into llx_c_currencies ( code, code_iso, active, label ) values ( 'FH', 'HUF', 1, 'Forint hongrois'); insert into llx_c_currencies ( code, code_iso, active, label ) values ( 'LK', 'LKR', 1, 'Roupie sri lanka'); + +-- +-- Taux TVA +-- + +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1,1, '0','0','Taux TVA non applicable (France, TOM)',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (2,1, '5.5','0','Taux à 5.5 (France hors DOMTOM)',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (3,1, '8.5','0','Taux à 8.5 (DOM sauf Guyane et Saint-Martin)',0); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (4,1, '8.5','1','Taux à 8.5 (DOM sauf Guyane et Saint-Martin), récupérable uniquement, non facturé',0); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (5,1,'19.6','0','Taux à 19.6 (France hors DOMTOM)',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (6,2, '0','0','Taux TVA non applicable',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (7,2, '6','0','Taux à 6',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (8,2, '21','0','Taux à 21',1); diff --git a/mysql/migration/1.1.0-2.0.0.sql b/mysql/migration/1.1.0-2.0.0.sql index 8003ec168fc..98dfe5dc30d 100644 --- a/mysql/migration/1.1.0-2.0.0.sql +++ b/mysql/migration/1.1.0-2.0.0.sql @@ -6,6 +6,29 @@ -- ; +drop table if exists llx_c_tva; + +create table llx_c_tva +( + rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY, + fk_pays integer NOT NULL, + taux double NOT NULL, + recuperableonly integer DEFAULT 0, + note varchar(128), + active tinyint DEFAULT 1 NOT NULL + +)type=innodb; + +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1,1, '0','0','Taux TVA non applicable (France, TOM)',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (2,1, '5.5','0','Taux à 5.5 (France hors DOMTOM)',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (3,1, '8.5','0','Taux à 8.5 (DOM sauf Guyane et Saint-Martin)',0); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (4,1, '8.5','1','Taux à 8.5 (DOM sauf Guyane et Saint-Martin), récupérable uniquement, non facturé',0); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (5,1,'19.6','0','Taux à 19.6 (France hors DOMTOM)',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (6,2, '0','0','Taux TVA non applicable',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (7,2, '6','0','Taux à 6',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (8,2, '21','0','Taux à 21',1); + + create table llx_user_clicktodial ( fk_user integer PRIMARY KEY,
'; print $valuetoshow; print '  '; + $html->selectyesno('recuperableonly','',1); + print '
* '.$langs->trans("LabelUsedByDefault").'.
* '.$langs->trans("LabelUsedByDefault").'.
 
'.$valuetoshow.'