1-- ===========================================================================
2-- Copyright (C) 2001-2003  Rodolphe Quiedeville    <rodolphe@quiedeville.org>
3-- Copyright (C) 2007-2017  Laurent Destailleur     <eldy@users.sourceforge.net>
4-- Copyright (C) 2007-2012  Regis Houssin           <regis.houssin@inodbox.com>
5-- Copyright (C) 2010       Juanjo Menent           <jmenent@2byte.es>
6-- Copyright (C) 2021       Alexandre Spangaro      <aspangaro@open-dsi.fr>
7--
8-- This program is free software; you can redistribute it and/or modify
9-- it under the terms of the GNU General Public License as published by
10-- the Free Software Foundation; either version 3 of the License, or
11-- (at your option) any later version.
12--
13-- This program is distributed in the hope that it will be useful,
14-- but WITHOUT ANY WARRANTY; without even the implied warranty of
15-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16-- GNU General Public License for more details.
17--
18-- You should have received a copy of the GNU General Public License
19-- along with this program. If not, see <https://www.gnu.org/licenses/>.
20--
21-- ===========================================================================
22
23create table llx_facture_fourn
24(
25  rowid					integer AUTO_INCREMENT PRIMARY KEY,
26  ref					varchar(180) NOT NULL,
27  ref_supplier			varchar(180) NOT NULL,
28  entity				integer  DEFAULT 1 NOT NULL,	 -- multi company id
29
30  ref_ext				varchar(255),                  -- reference into an external system (not used by dolibarr)
31
32  type					smallint DEFAULT 0 NOT NULL,
33  fk_soc				integer NOT NULL,
34
35  datec					datetime,                      -- date de creation de la facture
36  datef					date,                          -- date invoice
37  date_pointoftax		date DEFAULT NULL,			   -- date point of tax (for GB)
38  date_valid			date,						   -- date validation
39  tms					timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,                     -- last modification date
40  date_closing			datetime,                      -- date closing
41  libelle				varchar(255),
42  paye					smallint         DEFAULT 0 NOT NULL,
43  amount				double(24,8)     DEFAULT 0 NOT NULL,
44  remise				double(24,8)     DEFAULT 0,
45
46  close_code			varchar(16),		              -- Code motif cloture sans paiement complet
47  close_note			varchar(128),		              -- Commentaire cloture sans paiement complet
48
49  tva					double(24,8)     DEFAULT 0,
50  localtax1				double(24,8)     DEFAULT 0,
51  localtax2				double(24,8)     DEFAULT 0,
52  total					double(24,8)     DEFAULT 0,
53  total_ht				double(24,8)     DEFAULT 0,
54  total_tva				double(24,8)     DEFAULT 0,
55  total_ttc				double(24,8)     DEFAULT 0,
56
57  fk_statut				smallint DEFAULT 0 NOT NULL,
58
59  fk_user_author		integer,                       -- user making creation
60  fk_user_modif         integer,                       -- user making last change
61  fk_user_valid			integer,                       -- user validating
62  fk_user_closing		integer,					   -- user closing
63
64  fk_facture_source		integer,                       -- facture origine si facture avoir
65  fk_projet				integer,                       -- projet auquel est associee la facture
66
67  fk_account            integer,                       -- bank account
68  fk_cond_reglement		integer,   	                   -- condition de reglement (30 jours, fin de mois ...)
69  fk_mode_reglement		integer,                	   -- mode de reglement (CHQ, VIR, ...)
70  date_lim_reglement 	date,                          -- date limite de reglement
71
72  note_private			text,
73  note_public			text,
74  fk_incoterms          integer,						-- for incoterms
75  location_incoterms    varchar(255),					-- for incoterms
76
77  fk_transport_mode     integer,						-- for intracomm report
78
79  model_pdf				varchar(255),
80  last_main_doc			varchar(255),					-- relative filepath+filename of last main generated document
81
82  import_key			varchar(14),
83  extraparams			varchar(255),					-- for stock other parameters with json format
84
85  fk_multicurrency		integer,
86  multicurrency_code			varchar(255),
87  multicurrency_tx			double(24,8) DEFAULT 1,
88  multicurrency_total_ht		double(24,8) DEFAULT 0,
89  multicurrency_total_tva	double(24,8) DEFAULT 0,
90  multicurrency_total_ttc	double(24,8) DEFAULT 0
91)ENGINE=innodb;
92