From 0c5f504881996b83eecd121ce4649bbce58df041 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Sat, 2 Apr 2016 06:22:31 +0200 Subject: [PATCH 1/3] FIX: Accountancy - Correct the display of account_parent --- htdocs/accountancy/admin/account.php | 12 ++++++------ htdocs/accountancy/admin/card.php | 16 +++++++++++++--- htdocs/install/mysql/migration/3.9.0-4.0.0.sql | 2 ++ .../mysql/tables/llx_accounting_account.sql | 2 +- 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index 3f251e0090b..70f191f3679 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -161,11 +161,11 @@ if ($result) { print ''; print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; print ' '; print ''; print ''; @@ -190,7 +190,7 @@ if ($result) { print '' . $accountstatic->getNomUrl(1) . ''; print '' . $obj->label . ''; - if ($obj->account_parent) + if (! empty($obj->account_parent)) { $accountparent->id = $obj->rowid2; $accountparent->label = $obj->label2; diff --git a/htdocs/accountancy/admin/card.php b/htdocs/accountancy/admin/card.php index eeb94bddf60..8d1ef913e35 100644 --- a/htdocs/accountancy/admin/card.php +++ b/htdocs/accountancy/admin/card.php @@ -59,12 +59,17 @@ if ($action == 'add') { // Clean code $account_number = clean_account(GETPOST('account_number')); // Accounting account without zero on the right + if (GETPOST('account_category') <= 0) { + $account_parent = ''; + } else { + $account_parent = GETPOST('account_category','int'); + } $object->fk_pcg_version = $obj->pcg_version; $object->pcg_type = GETPOST('pcg_type'); $object->pcg_subtype = GETPOST('pcg_subtype'); $object->account_number = $account_number; - $object->account_parent = GETPOST('account_parent', 'int'); + $object->account_parent = $account_parent; $object->account_category = GETPOST('account_category'); $object->label = GETPOST('label', 'alpha'); $object->active = 1; @@ -96,12 +101,17 @@ if ($action == 'add') { // Clean code $account_number = clean_account(GETPOST('account_number')); // Accounting account without zero on the right - + if (GETPOST('account_category') <= 0) { + $account_parent = ''; + } else { + $account_parent = GETPOST('account_category','int'); + } + $object->fk_pcg_version = $obj->pcg_version; $object->pcg_type = GETPOST('pcg_type'); $object->pcg_subtype = GETPOST('pcg_subtype'); $object->account_number = $account_number; - $object->account_parent = GETPOST('account_parent', 'int'); + $object->account_parent = account_parent; $object->account_category = GETPOST('account_category'); $object->label = GETPOST('label', 'alpha'); 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 78dfbf95be9..b0e42872772 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 @@ -342,3 +342,5 @@ CREATE TABLE llx_c_accounting_category ( ) ENGINE=innodb; ALTER TABLE llx_c_accounting_category ADD UNIQUE INDEX uk_c_accounting_category(code); + +ALTER TABLE llx_accounting_account MODIFY COLUMN account_parent integer; diff --git a/htdocs/install/mysql/tables/llx_accounting_account.sql b/htdocs/install/mysql/tables/llx_accounting_account.sql index e8927cdfda5..d74c1b75105 100644 --- a/htdocs/install/mysql/tables/llx_accounting_account.sql +++ b/htdocs/install/mysql/tables/llx_accounting_account.sql @@ -29,7 +29,7 @@ create table llx_accounting_account pcg_type varchar(20) NOT NULL, pcg_subtype varchar(20) NOT NULL, account_number varchar(32) NOT NULL, - account_parent varchar(32), + account_parent integer, -- Hierarchic parent label varchar(255) NOT NULL, fk_accounting_category integer DEFAULT 0, fk_user_author integer DEFAULT NULL, From 33e88332872609f8abee1dea54c26f914901ee04 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Sun, 3 Apr 2016 10:47:21 +0200 Subject: [PATCH 2/3] Fix travis --- htdocs/core/lib/functions.lib.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index bedb2a78bae..8671638ce0c 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3423,26 +3423,26 @@ function price2num($amount,$rounding='',$alreadysqlnb=0) * @param string $forceunitoutput 'no' or numeric (-3, -6, ...) compared to $unit * @return string String to show dimensions */ -function showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round=-1, $forceunitouput='no') +function showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round=-1, $forceunitoutput='no') { require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; - if (($forceunitouput == 'no' && $dimension < 1/10000) || (is_numeric($forceunitouput) && $forceunitouput == -6)) + if (($forceunitoutput == 'no' && $dimension < 1/10000) || (is_numeric($forceunitoutput) && $forceunitoutput == -6)) { $dimension = $dimension * 1000000; $unit = $unit - 6; } - elseif (($forceunitouput == 'no' && $dimension < 1/10) || (is_numeric($forceunitouput) && $forceunitouput == -3)) + elseif (($forceunitoutput == 'no' && $dimension < 1/10) || (is_numeric($forceunitoutput) && $forceunitoutput == -3)) { $dimension = $dimension * 1000; $unit = $unit - 3; } - elseif (($forceunitouput == 'no' && $dimension > 100000000) || (is_numeric($forceunitouput) && $forceunitouput == 6)) + elseif (($forceunitoutput == 'no' && $dimension > 100000000) || (is_numeric($forceunitoutput) && $forceunitoutput == 6)) { $dimension = $dimension / 1000000; $unit = $unit + 6; } - elseif (($forceunitouput == 'no' && $dimension > 100000) || (is_numeric($forceunitouput) && $forceunitouput == 3)) + elseif (($forceunitoutput == 'no' && $dimension > 100000) || (is_numeric($forceunitoutput) && $forceunitoutput == 3)) { $dimension = $dimension / 1000; $unit = $unit + 3; From c48869e02bde509660c400c5d44ab9a524111ec7 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Sun, 3 Apr 2016 10:51:56 +0200 Subject: [PATCH 3/3] Bugfix --- htdocs/accountancy/admin/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/accountancy/admin/card.php b/htdocs/accountancy/admin/card.php index 8d1ef913e35..04d538b1b31 100644 --- a/htdocs/accountancy/admin/card.php +++ b/htdocs/accountancy/admin/card.php @@ -111,7 +111,7 @@ if ($action == 'add') { $object->pcg_type = GETPOST('pcg_type'); $object->pcg_subtype = GETPOST('pcg_subtype'); $object->account_number = $account_number; - $object->account_parent = account_parent; + $object->account_parent = $account_parent; $object->account_category = GETPOST('account_category'); $object->label = GETPOST('label', 'alpha');