diff --git a/CRM/Admin/Form/Preferences/Display.php b/CRM/Admin/Form/Preferences/Display.php index ea4745eea70b..b1605f3c9953 100644 --- a/CRM/Admin/Form/Preferences/Display.php +++ b/CRM/Admin/Form/Preferences/Display.php @@ -60,8 +60,7 @@ public function buildQuickForm() { //changes for freezing the invoices/credit notes checkbox if invoicing is uncheck $invoiceSettings = Civi::settings()->get('contribution_invoice_settings'); - $invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings); - $this->assign('invoicing', $invoicing); + $this->assign('invoicing', CRM_Invoicing_Utils::isInvoicingEnabled()); $this->addElement('submit', 'ckeditor_config', ts('Configure CKEditor')); diff --git a/CRM/Contribute/Form/Contribution.php b/CRM/Contribute/Form/Contribution.php index 732c366e24eb..c4d6cfee3239 100644 --- a/CRM/Contribute/Form/Contribution.php +++ b/CRM/Contribute/Form/Contribution.php @@ -496,8 +496,7 @@ public function buildQuickForm() { // build price set form. $buildPriceSet = FALSE; - $invoiceSettings = Civi::settings()->get('contribution_invoice_settings'); - $invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings); + $invoicing = CRM_Invoicing_Utils::isInvoicingEnabled(); $this->assign('invoicing', $invoicing); $buildRecurBlock = FALSE; diff --git a/CRM/Contribute/Form/ContributionView.php b/CRM/Contribute/Form/ContributionView.php index 8d3f74f59615..2a6cf9d9c8a0 100644 --- a/CRM/Contribute/Form/ContributionView.php +++ b/CRM/Contribute/Form/ContributionView.php @@ -190,7 +190,7 @@ public function preProcess() { // assign values to the template $this->assign($values); $invoiceSettings = Civi::settings()->get('contribution_invoice_settings'); - $invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings); + $invoicing = CRM_Invoicing_Utils::isInvoicingEnabled(); $this->assign('invoicing', $invoicing); $this->assign('isDeferred', CRM_Utils_Array::value('deferred_revenue_enabled', $invoiceSettings)); if ($invoicing && isset($values['tax_amount'])) { diff --git a/CRM/Contribute/Page/UserDashboard.php b/CRM/Contribute/Page/UserDashboard.php index 2b4687f234c5..f542441b745b 100644 --- a/CRM/Contribute/Page/UserDashboard.php +++ b/CRM/Contribute/Page/UserDashboard.php @@ -140,9 +140,8 @@ public function listContribution() { */ public function run() { $invoiceSettings = Civi::settings()->get('contribution_invoice_settings'); - $invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings); $defaultInvoicePage = CRM_Utils_Array::value('default_invoice_page', $invoiceSettings); - $this->assign('invoicing', $invoicing); + $this->assign('invoicing', CRM_Invoicing_Utils::isInvoicingEnabled()); $this->assign('defaultInvoicePage', $defaultInvoicePage); parent::preProcess(); $this->listContribution(); diff --git a/CRM/Invoicing/Utils.php b/CRM/Invoicing/Utils.php index 22994f4b2819..27ad5303312d 100644 --- a/CRM/Invoicing/Utils.php +++ b/CRM/Invoicing/Utils.php @@ -30,7 +30,6 @@ * @package CRM * @copyright CiviCRM LLC (c) 2004-2018 */ - class CRM_Invoicing_Utils { /** @@ -47,7 +46,7 @@ public static function onToggle($oldValue, $newValue, $metadata) { return; } $existingUserViewOptions = civicrm_api3('Setting', 'get', ['return' => 'user_dashboard_options'])['values'][CRM_Core_Config::domainID()]['user_dashboard_options']; - $optionValues= civicrm_api3('Setting', 'getoptions', ['field' => 'user_dashboard_options'])['values']; + $optionValues = civicrm_api3('Setting', 'getoptions', ['field' => 'user_dashboard_options'])['values']; $invoiceKey = array_search('Invoices / Credit Notes', $optionValues); $existingIndex = in_array($invoiceKey, $existingUserViewOptions); diff --git a/tests/phpunit/CRM/Contact/Page/View/UserDashBoardTest.php b/tests/phpunit/CRM/Contact/Page/View/UserDashBoardTest.php index 57473d09ba21..181ceda33c4f 100644 --- a/tests/phpunit/CRM/Contact/Page/View/UserDashBoardTest.php +++ b/tests/phpunit/CRM/Contact/Page/View/UserDashBoardTest.php @@ -88,9 +88,7 @@ public function testDashboardContentContributions() { */ public function testDashboardContentContributionsWithInvoicingEnabled() { $this->contributionCreate(['contact_id' => $this->contactID]); - $this->callAPISuccess('Setting', 'create', ['invoicing' => 1, 'contribution_invoice_settings' => [ - 'invoicing' => 1, - ]]); + $this->callAPISuccess('Setting', 'create', ['invoicing' => 1]); $this->runUserDashboard(); $expectedStrings = [ 'Your Contribution(s)',