From 88435a0d801f94f41629a79823718f1da4044c1a Mon Sep 17 00:00:00 2001
From: aspangaro <alexandre.spangaro@gmail.com>
Date: Sun, 1 May 2016 08:03:40 +0200
Subject: [PATCH] NEW: Accountancy - Prepare multiple journals

---
 .../install/mysql/migration/3.9.0-4.0.0.sql   | 10 +++++++
 .../tables/llx_accounting_journal.key.sql     | 20 ++++++++++++++
 .../mysql/tables/llx_accounting_journal.sql   | 27 +++++++++++++++++++
 3 files changed, 57 insertions(+)
 create mode 100644 htdocs/install/mysql/tables/llx_accounting_journal.key.sql
 create mode 100644 htdocs/install/mysql/tables/llx_accounting_journal.sql

diff --git a/htdocs/install/mysql/migration/3.9.0-4.0.0.sql b/htdocs/install/mysql/migration/3.9.0-4.0.0.sql
index a429ef5c7cf..86e84018919 100644
--- a/htdocs/install/mysql/migration/3.9.0-4.0.0.sql
+++ b/htdocs/install/mysql/migration/3.9.0-4.0.0.sql
@@ -373,6 +373,16 @@ UPDATE llx_accounting_account SET account_parent = '0' WHERE account_parent = ''
 -- VMYSQL4.1 ALTER TABLE llx_accounting_account MODIFY COLUMN account_parent integer DEFAULT 0;
 -- VPGSQL8.2 ALTER TABLE llx_accounting_account ALTER COLUMN account_parent TYPE integer USING account_parent::integer;
 
+CREATE TABLE llx_accounting_journal
+(
+  rowid             integer AUTO_INCREMENT PRIMARY KEY,
+  code       		varchar(32) NOT NULL,
+  label             varchar(128) NOT NULL,
+  nature			smallint DEFAULT 0 NOT NULL,			-- type of journals (Sale / purchase / bank / various operations)
+  active            smallint DEFAULT 0
+)ENGINE=innodb;
+
+ALTER TABLE llx_accounting_journal ADD UNIQUE INDEX uk_accounting_journal_code (code);
 
 -- VMYSQL4.1 DROP INDEX uk_bordereau_cheque ON llx_bordereau_cheque;
 -- VPGSQL8.2 DROP INDEX uk_bordereau_cheque;
diff --git a/htdocs/install/mysql/tables/llx_accounting_journal.key.sql b/htdocs/install/mysql/tables/llx_accounting_journal.key.sql
new file mode 100644
index 00000000000..e5083aa83d7
--- /dev/null
+++ b/htdocs/install/mysql/tables/llx_accounting_journal.key.sql
@@ -0,0 +1,20 @@
+-- ============================================================================
+-- Copyright (C) 2016	 Alexandre Spangaro	 <aspangaro.dolibarr@gmail.com>
+--
+-- This program is free software; you can redistribute it and/or modify
+-- it under the terms of the GNU General Public License as published by
+-- the Free Software Foundation; either version 3 of the License, or
+-- (at your option) any later version.
+--
+-- This program is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+-- GNU General Public License for more details.
+--
+-- You should have received a copy of the GNU General Public License
+-- along with this program. If not, see <http://www.gnu.org/licenses/>.
+--
+-- ===========================================================================
+
+
+ALTER TABLE llx_accounting_journal ADD UNIQUE INDEX uk_accounting_journal_code (code);
diff --git a/htdocs/install/mysql/tables/llx_accounting_journal.sql b/htdocs/install/mysql/tables/llx_accounting_journal.sql
new file mode 100644
index 00000000000..bc514f0ed9b
--- /dev/null
+++ b/htdocs/install/mysql/tables/llx_accounting_journal.sql
@@ -0,0 +1,27 @@
+-- ============================================================================
+-- Copyright (C) 2016	 Alexandre Spangaro	 <aspangaro.dolibarr@gmail.com>
+--
+-- This program is free software; you can redistribute it and/or modify
+-- it under the terms of the GNU General Public License as published by
+-- the Free Software Foundation; either version 3 of the License, or
+-- (at your option) any later version.
+--
+-- This program is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+-- GNU General Public License for more details.
+--
+-- You should have received a copy of the GNU General Public License
+-- along with this program. If not, see <http://www.gnu.org/licenses/>.
+--
+-- Table of journals for accountancy
+-- ============================================================================
+
+create table llx_accounting_journal
+(
+  rowid             integer AUTO_INCREMENT PRIMARY KEY,
+  code       		varchar(32) NOT NULL,
+  label             varchar(128) NOT NULL,
+  nature			smallint DEFAULT 0 NOT NULL,			-- type of journals (Sale / purchase / bank / various operations)
+  active            smallint DEFAULT 0
+)ENGINE=innodb;
-- 
GitLab