Use function to determinie if invoicing is enabled which accounts for historical...
authoreileen <emcnaughton@wikimedia.org>
Wed, 21 Nov 2018 00:49:42 +0000 (13:49 +1300)
committereileen <emcnaughton@wikimedia.org>
Wed, 21 Nov 2018 03:44:08 +0000 (16:44 +1300)
CRM/Admin/Form/Preferences/Display.php
CRM/Contribute/Form/Contribution.php
CRM/Contribute/Form/ContributionView.php
CRM/Contribute/Page/UserDashboard.php
CRM/Invoicing/Utils.php
tests/phpunit/CRM/Contact/Page/View/UserDashBoardTest.php

index ea4745eea70bd4d418fd64ef7b6c6a4e85880197..b1605f3c9953915180617963a038509026328a14 100644 (file)
@@ -60,8 +60,7 @@ class CRM_Admin_Form_Preferences_Display extends CRM_Admin_Form_Preferences {
 
     //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'));
 
index 732c366e24eb12b058221f19d7f1691cc469ffd2..c4d6cfee3239b9cfecd367546b205e18200cd41e 100644 (file)
@@ -496,8 +496,7 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP
 
     // 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;
index 8d3f74f59615e83b915a30b5dfd542426fe76532..2a6cf9d9c8a08f479d8c4459c5a3a472214254a7 100644 (file)
@@ -190,7 +190,7 @@ class CRM_Contribute_Form_ContributionView extends CRM_Core_Form {
     // 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'])) {
index 2b4687f234c5daedf0401a7ba530cbaad87f06bc..f542441b745b3f3fa1a24b8581b0fce6c4fb69f2 100644 (file)
@@ -140,9 +140,8 @@ class CRM_Contribute_Page_UserDashboard extends CRM_Contact_Page_View_UserDashBo
    */
   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();
index 22994f4b2819b965d73e138f395b9fa927f333bc..27ad5303312d00219ff4d7b42ca7bdf95da73985 100644 (file)
@@ -30,7 +30,6 @@
  * @package CRM
  * @copyright CiviCRM LLC (c) 2004-2018
  */
-
 class CRM_Invoicing_Utils {
 
   /**
@@ -47,7 +46,7 @@ class CRM_Invoicing_Utils {
       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);
 
index 57473d09ba2116b80825d9007dd481fb6e2e9b73..5dcdc8618f3987e8b2da6b01db3a72d1f3d99d9d 100644 (file)
@@ -51,6 +51,14 @@ class CRM_Contact_Page_View_UserDashBoardTest extends CiviUnitTestCase {
     $this->listenForPageContent();
   }
 
+  /**
+   * Clean up after each test.
+   */
+  public function tearDown() {
+    $this->quickCleanUpFinancialEntities();
+    $this->quickCleanup(['civicrm_uf_match']);
+  }
+
   /**
    * Test the content of the dashboard.
    */
@@ -88,9 +96,7 @@ class CRM_Contact_Page_View_UserDashBoardTest extends CiviUnitTestCase {
    */
   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)',