1-- ============================================================================
2-- Copyright (C) 2015		Laurent Destailleur  <eldy@users.sourceforge.net>
3--
4-- This program is free software; you can redistribute it and/or modify
5-- it under the terms of the GNU General Public License as published by
6-- the Free Software Foundation; either version 3 of the License, or
7-- (at your option) any later version.
8--
9-- This program is distributed in the hope that it will be useful,
10-- but WITHOUT ANY WARRANTY; without even the implied warranty of
11-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12-- GNU General Public License for more details.
13--
14-- You should have received a copy of the GNU General Public License
15-- along with this program. If not, see <https://www.gnu.org/licenses/>.
16--
17-- ============================================================================
18
19CREATE TABLE llx_expensereport_det
20(
21   rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY,
22   fk_expensereport integer NOT NULL,
23   docnumber varchar(128),										-- To store a ref of a accounting doc (piece)
24   fk_c_type_fees integer NOT NULL,								-- Type of expense
25   fk_c_exp_tax_cat integer,
26   fk_projet integer,											-- Id of project
27   comments text NOT NULL,
28   product_type integer DEFAULT -1,
29   qty real NOT NULL,
30   subprice						double(24,8) DEFAULT 0 NOT NULL, -- P.U. HT (example 100)
31   value_unit                   double(24,8) NOT NULL,          -- P.U. TTC (example 120)
32   remise_percent real,
33   vat_src_code					varchar(10)  DEFAULT '',		-- Vat code used as source of vat fields. Not strict foreign key here.
34   tva_tx						double(6,3),					-- Vat rate
35   localtax1_tx               	double(6,3)  DEFAULT 0,    		-- localtax1 rate
36   localtax1_type			 	varchar(10)	  	 NULL, 			-- localtax1 type
37   localtax2_tx               	double(6,3)  DEFAULT 0,    		-- localtax2 rate
38   localtax2_type			 	varchar(10)	  	 NULL, 			-- localtax2 type
39   total_ht double(24,8) DEFAULT 0 NOT NULL,
40   total_tva double(24,8) DEFAULT 0 NOT NULL,
41   total_localtax1				double(24,8)  	DEFAULT 0,		-- Total LocalTax1 for total quantity of line
42   total_localtax2				double(24,8)	DEFAULT 0,		-- total LocalTax2 for total quantity of line
43   total_ttc double(24,8) DEFAULT 0 NOT NULL,
44   date date NOT NULL,
45   info_bits					integer DEFAULT 0,				-- TVA NPR ou non
46   special_code					integer DEFAULT 0,			    -- code for special lines
47   fk_multicurrency             integer,
48   multicurrency_code           varchar(255),
49   multicurrency_subprice       double(24,8) DEFAULT 0,
50   multicurrency_total_ht       double(24,8) DEFAULT 0,
51   multicurrency_total_tva      double(24,8) DEFAULT 0,
52   multicurrency_total_ttc      double(24,8) DEFAULT 0,
53   fk_facture					integer DEFAULT 0,				-- ID of customer invoice line if expense is rebilled to a customer
54   fk_ecm_files        integer DEFAULT NULL,			-- ID of ECM file that is source document of expense report
55   fk_code_ventilation			integer DEFAULT 0,
56   rang							integer DEFAULT 0,				-- position of line
57   import_key					varchar(14),
58   rule_warning_message text
59) ENGINE=innodb;
60