dev/core#1558 retrieve credit_notes_prefix as a 'real' setting.
authoreileen <emcnaughton@wikimedia.org>
Thu, 30 Jan 2020 21:57:40 +0000 (10:57 +1300)
committereileen <emcnaughton@wikimedia.org>
Fri, 31 Jan 2020 06:55:15 +0000 (19:55 +1300)
    This is part of work to convert the non-standard contribution_invoice_settings array of settings into settings in line
    with our standards

CRM/Contribute/BAO/Contribution.php
api/v3/examples/Setting/GetFields.ex.php
tests/phpunit/CiviTest/CiviUnitTestCase.php
tests/phpunit/api/v3/ContributionTest.php

index 31f5418ff91747bfe8eb5e232951b45f7dc3830a..f353324661767ff0f22d0d1df42d4ede1d64ed0c 100644 (file)
@@ -4693,16 +4693,17 @@ INNER JOIN civicrm_activity ON civicrm_activity_contact.activity_id = civicrm_ac
    *
    * @return string
    *   Credit Note Id.
+   *
+   * @throws \CiviCRM_API3_Exception
    */
   public static function createCreditNoteId() {
-    $prefixValue = Civi::settings()->get('contribution_invoice_settings');
 
     $creditNoteNum = CRM_Core_DAO::singleValueQuery("SELECT count(creditnote_id) as creditnote_number FROM civicrm_contribution WHERE creditnote_id IS NOT NULL");
     $creditNoteId = NULL;
 
     do {
       $creditNoteNum++;
-      $creditNoteId = CRM_Utils_Array::value('credit_notes_prefix', $prefixValue) . "" . $creditNoteNum;
+      $creditNoteId = Civi::settings()->get('credit_notes_prefix') . '' . $creditNoteNum;
       $result = civicrm_api3('Contribution', 'getcount', [
         'sequential' => 1,
         'creditnote_id' => $creditNoteId,
index c188d7d591c37db102add6210b0e566ce5b629a1..2f479ace759adc232159c283853b09d21324d10d 100644 (file)
@@ -234,7 +234,6 @@ function setting_getfields_expectedresult() {
         'type' => 'Array',
         'default' => [
           'invoice_prefix' => 'INV_',
-          'credit_notes_prefix' => 'CN_',
           'due_date' => '10',
           'due_date_period' => 'days',
           'notes' => '',
index ad5b61781a06219dd1c245dabb2a5f504ef741cf..fd0e0b92775ebe7a3e90f2e55c8a73117201aee2 100644 (file)
@@ -3025,7 +3025,6 @@ VALUES
       [
         'invoicing' => 1,
         'invoice_prefix' => 'INV_',
-        'credit_notes_prefix' => 'CN_',
         'due_date' => 10,
         'due_date_period' => 'days',
         'notes' => '',
index f54bfd4f20fbea2fa2fa1bca193f4d77255bf95b..4083a906afd220557db899d148f95a085008984c 100644 (file)
@@ -1645,12 +1645,11 @@ class api_v3_ContributionTest extends CiviUnitTestCase {
 
   /**
    * Function tests that financial records are added when Pending Contribution is Canceled.
+   *
+   * @throws \CRM_Core_Exception
    */
   public function testCreateUpdateContributionCancelPending() {
-    // Enable & disable invoicing just to standardise the credit note id setting.
-    // Longer term we want to separate that setting from 'taxAndInvoicing'.
-    // and / or remove from core.
-    $this->enableTaxAndInvoicing();
+    Civi::settings()->set('credit_notes_prefix', 'CN_');
     $contribParams = [
       'contact_id' => $this->_individualId,
       'receive_date' => '2012-01-01',
@@ -1675,7 +1674,6 @@ class api_v3_ContributionTest extends CiviUnitTestCase {
     $this->_checkFinancialTrxn($contribution, 'cancelPending', NULL, $checkTrxnDate);
     $this->_checkFinancialItem($contribution['id'], 'cancelPending');
     $this->assertEquals('CN_1', $contribution['values'][$contribution['id']]['creditnote_id']);
-    $this->disableTaxAndInvoicing();
   }
 
   /**