Clean code
This commit is contained in:
parent
b379a2f83c
commit
db18db9488
@ -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 '<input type="hidden" name="action" value="display">';
|
||||
dol_fiche_head();
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
// Category
|
||||
|
||||
// Select the category
|
||||
print '<tr><td class="titlefield">' . $langs->trans("AccountingCategory") . '</td>';
|
||||
print '<td>';
|
||||
$formaccounting->select_accounting_category($cat_id, 'account_category', 1, 0, 0, 1);
|
||||
print '<input class="button" type="submit" value="' . $langs->trans("Select") . '">';
|
||||
print '</td></tr>';
|
||||
|
||||
// Select the accounts
|
||||
if (! empty($cat_id))
|
||||
{
|
||||
$return = $accountingcategory->getAccountsWithNoCategory($cat_id);
|
||||
@ -153,7 +161,7 @@ if ($action == 'display' || $action == 'delete') {
|
||||
print "</tr>\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');
|
||||
}
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -15,18 +15,20 @@
|
||||
-- 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 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;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user