This commit is contained in:
Laurent Destailleur 2017-03-03 15:06:17 +01:00
parent be86664e43
commit bef5f2c236
4 changed files with 228 additions and 223 deletions

View File

@ -151,7 +151,9 @@ $sql = "SELECT aa.rowid, aa.fk_pcg_version, aa.pcg_type, aa.pcg_subtype, aa.acco
$sql .= " a2.rowid as rowid2, a2.label as label2, a2.account_number as account_number2"; $sql .= " a2.rowid as rowid2, a2.label as label2, a2.account_number as account_number2";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa"; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON aa.account_parent = a2.rowid"; // Dirty hack wainting that foreign key account_parent is an integer to be compared correctly with rowid
if ($db->type == 'pgsql') $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON a2.rowid = CAST(aa.account_parent AS INTEGER)";
else $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON a2.rowid = CAST(aa.account_parent AS UNSIGNED)";
$sql .= " WHERE asy.rowid = " . $pcgver; $sql .= " WHERE asy.rowid = " . $pcgver;
if (strlen(trim($search_account))) { if (strlen(trim($search_account))) {

View File

@ -250,3 +250,6 @@ ALTER TABLE llx_projet_task ADD UNIQUE INDEX uk_projet_task_ref (ref, entity);
ALTER TABLE llx_contrat ADD COLUMN fk_user_modif integer; ALTER TABLE llx_contrat ADD COLUMN fk_user_modif integer;
update llx_accounting_account set account_parent = 0 where account_parent = '';

View File

@ -29,7 +29,7 @@ create table llx_accounting_account
pcg_type varchar(20) NOT NULL, pcg_type varchar(20) NOT NULL,
pcg_subtype varchar(20) NOT NULL, pcg_subtype varchar(20) NOT NULL,
account_number varchar(32) NOT NULL, account_number varchar(32) NOT NULL,
account_parent varchar(32) DEFAULT '0', -- Hierarchic parent 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, label varchar(255) NOT NULL,
fk_accounting_category integer DEFAULT 0, fk_accounting_category integer DEFAULT 0,
fk_user_author integer DEFAULT NULL, fk_user_author integer DEFAULT NULL,