From 0fc7ad7c1fea60bd59fe6cd20518c327a47862b8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 24 May 2019 18:05:29 +0200 Subject: [PATCH] Add one param to fetch of accounting account to solve chart import --- .../accountancy/class/accountingaccount.class.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php index 886e19577fb..d01a48d1664 100644 --- a/htdocs/accountancy/class/accountingaccount.class.php +++ b/htdocs/accountancy/class/accountingaccount.class.php @@ -149,12 +149,13 @@ class AccountingAccount extends CommonObject /** * Load record in memory * - * @param int $rowid Id - * @param string $account_number Account number - * @param int $limittocurrentchart 1=Do not load record if it is into another accounting system - * @return int <0 if KO, 0 if not found, Id of record if OK and found + * @param int $rowid Id + * @param string $account_number Account number + * @param int|boolean $limittocurrentchart 1 or true=Load record only if it is into current active char of account + * @param string $limittochartaccount 'ABC'=Load record only if it is into chart account with code 'ABC'. + * @return int <0 if KO, 0 if not found, Id of record if OK and found */ - function fetch($rowid = null, $account_number = null, $limittocurrentchart = 0) + function fetch($rowid = null, $account_number = null, $limittocurrentchart = 0, $limittoachartaccount = '') { global $conf; @@ -172,6 +173,9 @@ class AccountingAccount extends CommonObject if (! empty($limittocurrentchart)) { $sql .= ' AND a.fk_pcg_version IN (SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $this->db->escape($conf->global->CHARTOFACCOUNTS) . ')'; } + if (! empty($limittoachartaccount)) { + $sql .= " AND a.fk_pcg_version = '".$this->db->escape($limittoachartaccount)."')"; + } dol_syslog(get_class($this) . "::fetch sql=" . $sql, LOG_DEBUG); $result = $this->db->query($sql);