diff --git a/htdocs/accountancy/admin/categories.php b/htdocs/accountancy/admin/categories.php index 7ab463e3179..a91c22ffe4c 100644 --- a/htdocs/accountancy/admin/categories.php +++ b/htdocs/accountancy/admin/categories.php @@ -53,6 +53,11 @@ if (empty($user->rights->accounting->chartofaccount)) $accountingcategory = new AccountancyCategory($db); + +/* + * Actions + */ + // si ajout de comptes if (! empty($selectcpt)) { $cpts = array (); @@ -83,6 +88,7 @@ if ($action == 'delete') { /* * View */ + $form = new Form($db); $formaccounting = new FormAccounting($db); @@ -99,13 +105,15 @@ print ''; dol_fiche_head(); print ''; -// Category + +// Select the category print ''; print ''; +// Select the accounts if (! empty($cat_id)) { $return = $accountingcategory->getAccountsWithNoCategory($cat_id); @@ -153,7 +161,7 @@ if ($action == 'display' || $action == 'delete') { print "\n"; if (! empty($cat_id)) { - $return = $accountingcategory->display($cat_id); + $return = $accountingcategory->display($cat_id); // This load ->lines_display if ($return < 0) { setEventMessages(null, $accountingcategory->errors, 'errors'); } diff --git a/htdocs/accountancy/class/accountancycategory.class.php b/htdocs/accountancy/class/accountancycategory.class.php index 92d0f9e4499..2f6a630acd4 100644 --- a/htdocs/accountancy/class/accountancycategory.class.php +++ b/htdocs/accountancy/class/accountancycategory.class.php @@ -357,7 +357,6 @@ class AccountancyCategory // extends CommonObject * Function to select all accounting accounts from an accounting category * * @param int $id Id - * * @return int <0 if KO, 0 if not found, >0 if OK */ public function display($id) { @@ -365,7 +364,7 @@ class AccountancyCategory // extends CommonObject $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as t"; $sql .= " WHERE t.fk_accounting_category = " . $id; - $this->lines_display = array (); + $this->lines_display = array()); dol_syslog(__METHOD__ . " sql=" . $sql, LOG_DEBUG); $resql = $this->db->query($sql); diff --git a/htdocs/install/mysql/data/llx_accounting_category.sql b/htdocs/install/mysql/data/llx_accounting_category.sql index 4954ed3f0fc..d6a9629a5fd 100644 --- a/htdocs/install/mysql/data/llx_accounting_category.sql +++ b/htdocs/install/mysql/data/llx_accounting_category.sql @@ -17,8 +17,8 @@ -- --- Group of accounting account for French result. This is a minimal default setup. -INSERT INTO llx_c_accounting_category (rowid, code, label, range_account, sens, category_type, formula, position, fk_country, active) VALUES ( 1, 'VENTES', 'Income of products/services', 'Example: 7xxxxx', 0, 0, '', '10', 1, 1); -INSERT INTO llx_c_accounting_category (rowid, code, label, range_account, sens, category_type, formula, position, fk_country, active) VALUES ( 2, 'DEPENSES', 'Expenses of products/services', 'Example: 6xxxxx', 0, 0, '', '20', 1, 1); +-- Group of accounting account for French reports. This is a minimal default setup. +INSERT INTO llx_c_accounting_category (rowid, code, label, range_account, sens, category_type, formula, position, fk_country, active) VALUES ( 1, 'INCOME', 'Income of products/services', 'Example: 7xxxxx', 0, 0, '', '10', 1, 1); +INSERT INTO llx_c_accounting_category (rowid, code, label, range_account, sens, category_type, formula, position, fk_country, active) VALUES ( 2, 'EXPENSES', 'Expenses of products/services', 'Example: 6xxxxx', 0, 0, '', '20', 1, 1); INSERT INTO llx_c_accounting_category (rowid, code, label, range_account, sens, category_type, formula, position, fk_country, active) VALUES ( 3, 'PROFIT', 'Balance', '', 0, 1, 'VENTES+DEPENSES', '30', 1, 1); diff --git a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql index 442b99fbfb1..e6296bb8eae 100644 --- a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql +++ b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql @@ -705,3 +705,6 @@ ALTER TABLE llx_facture_rec_extrafields ADD INDEX idx_facture_rec_extrafields (f -- VMYSQL4.1 ALTER TABLE llx_product_association ADD COLUMN rowid integer AUTO_INCREMENT PRIMARY KEY; + +DROP TABLE llx_c_accountancy_category; + diff --git a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql index 534cba912d5..0e5d4e51bb9 100644 --- a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql +++ b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql @@ -36,6 +36,7 @@ ALTER TABLE llx_website_page ADD COLUMN fk_user_create integer; ALTER TABLE llx_website_page ADD COLUMN fk_user_modif integer; ALTER TABLE llx_website_page ADD COLUMN type_container varchar(16) NOT NULL DEFAULT 'page'; +DROP TABLE llx_c_accountancy_category; -- For 8.0 diff --git a/htdocs/install/mysql/tables/llx_accounting_account.sql b/htdocs/install/mysql/tables/llx_accounting_account.sql index 385d6b43bc8..aa82664f931 100644 --- a/htdocs/install/mysql/tables/llx_accounting_account.sql +++ b/htdocs/install/mysql/tables/llx_accounting_account.sql @@ -25,13 +25,13 @@ create table llx_accounting_account entity integer DEFAULT 1 NOT NULL, datec datetime, tms timestamp, - fk_pcg_version varchar(32) NOT NULL, - pcg_type varchar(20) NOT NULL, - pcg_subtype varchar(20) NOT NULL, + fk_pcg_version varchar(32) NOT NULL, -- Chart system + pcg_type varchar(20) NOT NULL, -- First part of Key for predefined groups + pcg_subtype varchar(20) NOT NULL, -- Second part of Key for predefined groups account_number varchar(32) NOT NULL, - account_parent varchar(32) DEFAULT '0', -- Hierarchic parent TODO Move this as integer, it is a foreign key of llx_accounting_account.rowid + account_parent varchar(32) DEFAULT '0', -- Hierarchic parent. TODO Move this as integer, it is a foreign key of llx_accounting_account.rowid label varchar(255) NOT NULL, - fk_accounting_category integer DEFAULT 0, + fk_accounting_category integer DEFAULT 0, -- ID of personalized group for report fk_user_author integer DEFAULT NULL, fk_user_modif integer DEFAULT NULL, active tinyint DEFAULT 1 NOT NULL, diff --git a/htdocs/install/mysql/tables/llx_c_accounting_category.sql b/htdocs/install/mysql/tables/llx_c_accounting_category.sql index 683478aceef..253ff6aef46 100644 --- a/htdocs/install/mysql/tables/llx_c_accounting_category.sql +++ b/htdocs/install/mysql/tables/llx_c_accounting_category.sql @@ -15,18 +15,20 @@ -- You should have received a copy of the GNU General Public License -- along with this program. If not, see . -- --- Table with category for accounting account +-- Table with category for accounting account. +-- Note: Each accounting account is inside one chart system, so we can have +-- a different dispatching of account in a category for each chart system. -- =================================================================== CREATE TABLE llx_c_accounting_category ( - rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY, - code varchar(16) NOT NULL, - label varchar(255) NOT NULL, - range_account varchar(255) NOT NULL, - sens tinyint NOT NULL DEFAULT '0', -- For international accounting 0 : credit - debit / 1 : debit - credit - category_type tinyint NOT NULL DEFAULT '0', -- Field calculated or not - formula varchar(255) NOT NULL, -- Example : 1 + 2 (rowid of the category) - position integer DEFAULT 0, - fk_country integer DEFAULT NULL, -- This category is dedicated to a country - active integer DEFAULT 1 + rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY, + code varchar(16) NOT NULL, + label varchar(255) NOT NULL, + range_account varchar(255) NOT NULL, -- Comment + sens tinyint NOT NULL DEFAULT '0', -- For international accounting 0 : credit - debit / 1 : debit - credit + category_type tinyint NOT NULL DEFAULT '0', -- Field calculated or not + formula varchar(255) NOT NULL, -- Example : 1 + 2 (rowid of the category) + position integer DEFAULT 0, + fk_country integer DEFAULT NULL, -- This category is dedicated to a country + active integer DEFAULT 1 ) ENGINE=innodb;
' . $langs->trans("AccountingCategory") . ''; $formaccounting->select_accounting_category($cat_id, 'account_category', 1, 0, 0, 1); print ''; print '