CI =& get_instance(); $this->CI->config->load('accounting', true); $this->tableAvailable = $this->CI->db->table_exists('system_account_mappings'); } public function get($key, $required = true) { if (array_key_exists($key, $this->cache)) { return $this->cache[$key]; } $accountId = null; if ($this->tableAvailable) { $row = $this->CI->db ->select('account_id') ->where('mapping_key', $key) ->where('is_active', 1) ->get('system_account_mappings') ->row(); if ($row) { $accountId = (int) $row->account_id; } } if (!$accountId) { $fallbacks = (array) $this->CI->config->item('system_accounts', 'accounting'); $accountId = isset($fallbacks[$key]) ? (int) $fallbacks[$key] : null; } if (!$accountId && $required) { throw new BusinessException('Mapping akun sistem "' . $key . '" belum dikonfigurasi.'); } $this->cache[$key] = $accountId; return $accountId; } }