1-- ============================================================================
2-- Copyright (C) 2004		Rodolphe Quiedeville <rodolphe@quiedeville.org>
3-- Copyright (C) 2010-2013	Juanjo Menent        <jmenent@2byte.es>
4--
5-- This program is free software; you can redistribute it and/or modify
6-- it under the terms of the GNU General Public License as published by
7-- the Free Software Foundation; either version 3 of the License, or
8-- (at your option) any later version.
9--
10-- This program is distributed in the hope that it will be useful,
11-- but WITHOUT ANY WARRANTY; without even the implied warranty of
12-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13-- GNU General Public License for more details.
14--
15-- You should have received a copy of the GNU General Public License
16-- along with this program. If not, see <https://www.gnu.org/licenses/>.
17--
18-- ============================================================================
19
20create table llx_contratdet
21(
22  rowid                 integer AUTO_INCREMENT PRIMARY KEY,
23  tms                   timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
24
25  fk_contrat            integer       NOT NULL,
26  fk_product            integer       NULL,                -- doit pouvoir etre nul pour ligne detail sans produits
27
28  statut                smallint      DEFAULT 0,
29
30  label                 text,                              -- libelle du produit
31  description           text,
32  fk_remise_except		integer       NULL,                -- Lien vers table des remises fixes
33
34  date_commande         datetime,
35  date_ouverture_prevue datetime,
36  date_ouverture        datetime,                          -- date d'ouverture du service chez le client
37  date_fin_validite     datetime,
38  date_cloture          datetime,
39
40  vat_src_code			varchar(10)   DEFAULT '',		   -- Vat code used as source of vat fields. Not strict foreign key here.
41  tva_tx                double(6,3)   DEFAULT 0, 	       -- taux tva
42  localtax1_tx		    double(6,3)   DEFAULT 0,           -- local tax 1 rate
43  localtax1_type		varchar(10)	  	 NULL, 		       -- localtax1 type
44  localtax2_tx		    double(6,3)   DEFAULT 0,           -- local tax 2 rate
45  localtax2_type		varchar(10)	  	 NULL, 			   -- localtax2 type
46  qty                   real          NOT NULL,            -- quantity
47  remise_percent        real          DEFAULT 0,    	   -- pourcentage de remise
48  subprice              double(24,8)  DEFAULT 0,           -- prix unitaire
49  price_ht              real,              		           -- prix final (obsolete)
50  remise                real          DEFAULT 0,    		             -- montant de la remise (obsolete)
51  total_ht              double(24,8)  DEFAULT 0,     		   -- Total HT de la ligne toute quantite et incluant remise ligne et globale
52  total_tva             double(24,8)  DEFAULT 0,	   		   -- Total TVA de la ligne toute quantite et incluant remise ligne et globale
53  total_localtax1       double(24,8)  DEFAULT 0,	   		   -- Total Local tax 1 de la ligne
54  total_localtax2       double(24,8)  DEFAULT 0,	   		   -- Total Local tax 2 de la ligne
55  total_ttc             double(24,8)  DEFAULT 0,	   		   -- Total TTC de la ligne toute quantite et incluant remise ligne et globale
56  product_type			integer       DEFAULT 1,               -- Type of line (1=service by default)
57  info_bits		        integer DEFAULT 0, 		               -- TVA NPR ou non
58
59  buy_price_ht          double(24,8)  DEFAULT NULL,            -- buying price
60  fk_product_fournisseur_price integer DEFAULT NULL,           -- reference of supplier price when line was added was created (may be used to update buy_price_ht when future invoice will be created)
61
62  fk_user_author        integer       NOT NULL DEFAULT 0,
63  fk_user_ouverture     integer,
64  fk_user_cloture       integer,
65  commentaire           text,
66  fk_unit               integer       DEFAULT NULL,
67
68  fk_multicurrency		integer,
69  multicurrency_code			varchar(255),
70  multicurrency_subprice		double(24,8) DEFAULT 0,
71  multicurrency_total_ht		double(24,8) DEFAULT 0,
72  multicurrency_total_tva	double(24,8) DEFAULT 0,
73  multicurrency_total_ttc	double(24,8) DEFAULT 0
74)ENGINE=innodb;
75