protected function _execute() { if (!$this->_date) { throw new Exception("Invalid report date: none provided."); } if ($this->_date != date("Y-m-d", strtotime($this->_date))) { throw new Exception("Invalid report date: must be in format YYYY-MM-DD."); } $account_chart = new Beans_Account_Chart($this->_beans_data_auth()); $account_chart_result = $account_chart->execute(); if (!$account_chart_result->success) { throw new Exception("Error loading chart of accounts: " . $account_chart_result->auth_error . $account_chart_result->error); } $accounts = $this->_generate_simple_accounts($account_chart_result->data->accounts, $this->_date); $credit_total = $this->_generate_credit_total($accounts); $debit_total = $this->_generate_debit_total($accounts); return (object) array('date' => $this->_date, 'accounts' => $accounts, 'debit_total' => $debit_total, 'credit_total' => $credit_total); }
/** * Adds a few Beans_ calls to each view ( such as company settings ). */ protected function _beans_default_calls() { // Get Version $b = new Beans(); $this->_view->beansbooks_version = $b->get_version(); // Only if logged in. if (!strlen(Session::instance()->get('auth_uid')) or !strlen(Session::instance()->get('auth_key')) or !strlen(Session::instance()->get('auth_expiration'))) { return FALSE; } $setup_company_list = new Beans_Setup_Company_List($this->_beans_data_auth()); $setup_company_list_result = $setup_company_list->execute(); if ($this->_beans_result_check($setup_company_list_result)) { $this->_view->setup_company_list_result = $setup_company_list_result; } $account_chart = new Beans_Account_Chart($this->_beans_data_auth()); $account_chart_result = $account_chart->execute(); if ($this->_beans_result_check($account_chart_result)) { $this->_view->account_chart_result = $account_chart_result; } $account_type_search = new Beans_Account_Type_Search($this->_beans_data_auth()); $account_type_search_result = $account_type_search->execute(); if ($this->_beans_result_check($account_type_search_result)) { $this->_view->account_type_search_result = $account_type_search_result; } // We don't want to override something set elsewhere - like in Controller_View_Setup -> action_taxes() if (!isset($this->_view->tax_search_result)) { $tax_search = new Beans_Tax_Search($this->_beans_data_auth((object) array('search_include_hidden' => TRUE))); $tax_search_result = $tax_search->execute(); if ($this->_beans_result_check($tax_search_result)) { $this->_view->tax_search_result = $tax_search_result; } } }