1-- ========================================================================
2-- Copyright (C) 2000-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3-- Copyright (C) 2004-2017 Laurent Destailleur  <eldy@users.sourceforge.net>
4-- Copyright (C) 2005-2010 Regis Houssin        <regis.houssin@inodbox.com>
5-- Copyright (C) 2010      Juanjo Menent        <dolibarr@2byte.es>
6-- Copyright (C) 2014      Teddy Andreotti      <125155@supinfo.com>
7-- Copyright (C) 2015      Marcos García        <marcosgdf@gmail.com>
8--
9-- This program is free software; you can redistribute it and/or modify
10-- it under the terms of the GNU General Public License as published by
11-- the Free Software Foundation; either version 3 of the License, or
12-- (at your option) any later version.
13--
14-- This program is distributed in the hope that it will be useful,
15-- but WITHOUT ANY WARRANTY; without even the implied warranty of
16-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17-- GNU General Public License for more details.
18--
19-- You should have received a copy of the GNU General Public License
20-- along with this program. If not, see <https://www.gnu.org/licenses/>.
21--
22-- ========================================================================
23
24create table llx_societe
25(
26  rowid                    integer AUTO_INCREMENT PRIMARY KEY,
27  nom                      varchar(128),                                -- company reference name (should be same length than adherent.societe)
28  name_alias               varchar(128) NULL,
29  entity                   integer DEFAULT 1 NOT NULL,                  -- multi company id
30
31  ref_ext                  varchar(255),                                -- reference into an external system (not used by dolibarr)
32  ref_int                  varchar(255),                                -- reference into an internal system (deprecated)
33
34  statut                   tinyint        DEFAULT 0,            		-- statut
35  parent                   integer,
36
37  status            	   tinyint 		  DEFAULT 1,			        -- cessation d'activité ( 1 -- en activité, 0 -- cessation d'activité)
38
39  code_client              varchar(24),                         		-- code client
40  code_fournisseur         varchar(24),                         		-- code founisseur
41  code_compta              varchar(24),                         		-- code compta client
42  code_compta_fournisseur  varchar(24),                         		-- code compta founisseur
43  address                  varchar(255),                        		-- company address
44  zip                      varchar(25),                         		-- zipcode
45  town                     varchar(50),                         		-- town
46  fk_departement           integer        DEFAULT 0,            		--
47  fk_pays                  integer        DEFAULT 0,            		--
48  fk_account               integer        DEFAULT 0,            		--
49  phone                    varchar(20),                         		-- phone number
50  fax                      varchar(20),                         		-- fax number
51  url                      varchar(255),                        		--
52  email                    varchar(128),                        		--
53
54  socialnetworks           text DEFAULT NULL,                           -- json with socialnetworks
55  skype                    varchar(255),                        		-- deprecated
56  twitter                  varchar(255),                        		-- deprecated
57  facebook                 varchar(255),                        		-- deprecated
58  linkedin                 varchar(255),                        		-- deprecated
59  instagram                varchar(255),                        		-- deprecated
60  snapchat                 varchar(255),                        		-- deprecated
61  googleplus               varchar(255),                        		-- deprecated
62  youtube                  varchar(255),                        		-- deprecated
63  whatsapp                 varchar(255),                        		-- deprecated
64
65  fk_effectif              integer        DEFAULT 0,            		--
66  fk_typent                integer        DEFAULT NULL,                 -- type ent
67  fk_forme_juridique       integer        DEFAULT 0,            		-- juridical status
68  fk_currency			   varchar(3),									-- default currency
69  siren	                   varchar(128),                         		-- IDProf1: depends on country (example: siren or RCS for france, ...)
70  siret                    varchar(128),                         		-- IDProf2: depends on country (example: siret for france, ...)
71  ape                      varchar(128),                         		-- IDProf3: depends on country (example: code ape for france, ...)
72  idprof4                  varchar(128),                         		-- IDProf4: depends on country (example: nu for france, ...)
73  idprof5                  varchar(128),                         		-- IDProf5: depends on country (example: nu for france, ...)
74  idprof6                  varchar(128),                         		-- IDProf6: depends on country (example: nu for france, ...
75  tva_intra                varchar(20),                         		-- vat numero
76  capital                  double(24,8)   DEFAULT NULL,        			-- capital of company
77  fk_stcomm                integer        DEFAULT 0 NOT NULL,      		-- commercial status
78  note_private             text,                                		--
79  note_public              text,                                        --
80  model_pdf				   varchar(255),
81  prefix_comm              varchar(5),                          		-- prefix commercial (deprecated)
82  client                   tinyint        DEFAULT 0,            		-- client 0/1/2
83  fournisseur              tinyint        DEFAULT 0,            		-- fournisseur 0/1
84  supplier_account         varchar(32),                         		-- Id of our customer account known by the supplier
85  fk_prospectlevel         varchar(12),                         		-- prospect level (in llx_c_prospectlevel)
86  fk_incoterms             integer,										-- for incoterms
87  location_incoterms       varchar(255),								-- for incoterms
88  customer_bad             tinyint        DEFAULT 0,            		-- mauvais payeur 0/1
89  customer_rate            real           DEFAULT 0,            		-- taux fiabilite client (0 a 1)
90  supplier_rate            real           DEFAULT 0,            		-- taux fiabilite fournisseur (0 a 1)
91  remise_client            real           DEFAULT 0,            		-- discount by default granted to this customer
92  remise_supplier          real           DEFAULT 0,            		-- discount by default granted by this supplier
93  mode_reglement           tinyint,                             		-- payment mode customer
94  cond_reglement           tinyint,                             		-- payment term customer
95  transport_mode           tinyint,                             		-- transport mode customer (Intracomm report)
96  mode_reglement_supplier  tinyint,                             		-- payment mode supplier
97  cond_reglement_supplier  tinyint,                             		-- payment term supplier
98  transport_mode_supplier  tinyint,                             		-- transport mode supplier (Intracomm report)
99  fk_shipping_method       integer,                                     -- preferred shipping method id
100  tva_assuj                tinyint        DEFAULT 1,	        		-- assujeti ou non a la TVA
101  localtax1_assuj          tinyint        DEFAULT 0,	        		-- assujeti ou non a local tax 1
102  localtax1_value 		   double(6,3),
103  localtax2_assuj          tinyint        DEFAULT 0,	        		-- assujeti ou non a local tax 2
104  localtax2_value 		   double(6,3),
105  barcode                  varchar(180),                        		-- barcode
106  fk_barcode_type          integer NULL   DEFAULT 0,                    -- barcode type
107  price_level              integer NULL,                        		-- level of price for multiprices
108  outstanding_limit	       double(24,8)   DEFAULT NULL,					-- allowed outstanding limit
109  order_min_amount	       double(24,8)   DEFAULT NULL,					-- min amount for orders
110  supplier_order_min_amount	       double(24,8)   DEFAULT NULL,			-- min amount for supplier orders
111  default_lang             varchar(6),									-- default language
112  logo                     varchar(255)   DEFAULT NULL,
113  logo_squarred            varchar(255)   DEFAULT NULL,
114  canvas				   varchar(32)    DEFAULT NULL,	                -- type of canvas if used (null by default)
115  fk_warehouse			   integer 		  DEFAULT NULL,					-- if we need a link between third party and warehouse
116  webservices_url          varchar(255),                            	-- supplier webservice url
117  webservices_key          varchar(128),                            	-- supplier webservice key
118
119  accountancy_code_sell         varchar(32),                            -- Selling accountancy code
120  accountancy_code_buy          varchar(32),                            -- Buying accountancy code
121
122  tms                      timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,									-- last modification date
123  datec	                   datetime,                            		-- creation date
124  fk_user_creat            integer NULL,                        		-- utilisateur qui a cree l'info
125  fk_user_modif            integer,                             		-- utilisateur qui a modifie l'info
126
127  fk_multicurrency		   integer,
128  multicurrency_code	   varchar(255),
129
130  import_key               varchar(14)                          		-- import key
131)ENGINE=innodb;
132