dev/financial#54 check the correct place for deferred_revenut settings
authorEileen McNaughton <eileenmcnaughton@Eileens-MacBook-Pro.local>
Sun, 19 May 2019 22:09:59 +0000 (10:09 +1200)
committereileen <emcnaughton@wikmedia.org>
Tue, 21 May 2019 06:50:33 +0000 (18:50 +1200)
Currently we have a non-std store for invoicing settings that we are checking, yet the form saves it using our stds.

This updates checks for these settings to actually check the right place

CRM/Contribute/BAO/Contribution.php
CRM/Contribute/Form/Contribution.php
CRM/Event/Form/ManageEvent/Fee.php
CRM/Event/Form/Participant.php
CRM/Event/Form/Registration/Confirm.php
CRM/Financial/BAO/FinancialAccount.php
CRM/Member/Form/MembershipType.php
tests/phpunit/CRM/Contribute/BAO/ContributionTest.php

index 8f1fd8db46e51045e8cf1b3fbaaefcc41c151237..2afb3597fc6a77ed25f7ea50630c6ed178f2cd85 100644 (file)
@@ -166,7 +166,7 @@ class CRM_Contribute_BAO_Contribution extends CRM_Contribute_DAO_Contribution {
 
     if (!$contributionID
       && CRM_Utils_Array::value('membership_id', $params)
-      && self::checkContributeSettings('deferred_revenue_enabled')
+      && Civi::settings()->get('deferred_revenue_enabled')
     ) {
       $memberStartDate = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $params['membership_id'], 'start_date');
       if ($memberStartDate) {
@@ -5562,7 +5562,7 @@ LIMIT 1;";
    * @return null
    */
   public static function recordAlwaysAccountsReceivable(&$trxnParams, $contributionParams) {
-    if (!self::checkContributeSettings('always_post_to_accounts_receivable')) {
+    if (!Civi::settings()->get('always_post_to_accounts_receivable')) {
       return NULL;
     }
     $statusId = $contributionParams['contribution']->contribution_status_id;
index ab46198a0b7aaf84a2e5be3730a4790a9cc0dbcc..5258258aedd2b8c35412cfe79102e2160159c775 100644 (file)
@@ -692,7 +692,7 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP
     }
 
     // CRM-16189, add Revenue Recognition Date
-    if (CRM_Contribute_BAO_Contribution::checkContributeSettings('deferred_revenue_enabled')) {
+    if (Civi::settings()->get('deferred_revenue_enabled')) {
       $revenueDate = $this->add('date', 'revenue_recognition_date', ts('Revenue Recognition Date'), CRM_Core_SelectValues::date(NULL, 'M Y', NULL, 5));
       if ($this->_id && !CRM_Contribute_BAO_Contribution::allowUpdateRevenueRecognitionDate($this->_id)) {
         $revenueDate->freeze();
index 3a02919e228bd67f8a84a0e82dbda266f13686ba..ddc1c2da065fec87d9e8aa72b922785207cd76bc 100644 (file)
@@ -374,7 +374,7 @@ class CRM_Event_Form_ManageEvent_Fee extends CRM_Event_Form_ManageEvent {
     $this->addElement('submit', $this->getButtonName('submit'), ts('Add Discount Set to Fee Table'),
       ['class' => 'crm-form-submit cancel']
     );
-    if (CRM_Contribute_BAO_Contribution::checkContributeSettings('deferred_revenue_enabled')) {
+    if (Civi::settings()->get('deferred_revenue_enabled')) {
       $deferredFinancialType = CRM_Financial_BAO_FinancialAccount::getDeferredFinancialType();
       $this->assign('deferredFinancialType', array_keys($deferredFinancialType));
     }
index 0b0b31e0dcf2ff42c5874882f8d7ae53d5253b41..3cd49af6c1998182303af86afe6c95f8a4ffbfa5 100644 (file)
@@ -1002,7 +1002,7 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment
       $contributionParams = ['skipCleanMoney' => TRUE];
       $lineItem = [];
       $additionalParticipantDetails = [];
-      if (CRM_Contribute_BAO_Contribution::checkContributeSettings('deferred_revenue_enabled')) {
+      if (Civi::settings()->get('deferred_revenue_enabled')) {
         $eventStartDate = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $this->_eventId, 'start_date');
         if (strtotime($eventStartDate) > strtotime(date('Ymt'))) {
           $contributionParams['revenue_recognition_date'] = date('Ymd', strtotime($eventStartDate));
index bc800a62a5d4f61c6389efbfae848c577f0376a4..8bebdb1e6ab47a7e09538c6543aa4c8cc3845872 100644 (file)
@@ -1052,7 +1052,7 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration {
       );
     }
 
-    if (CRM_Contribute_BAO_Contribution::checkContributeSettings('deferred_revenue_enabled')) {
+    if (Civi::settings()->get('deferred_revenue_enabled')) {
       $eventStartDate = CRM_Utils_Array::value(
         'start_date',
         CRM_Utils_Array::value(
index 02ff4d9de89dd0440b1c3d3afafa92712ea66a26..c8f33573705bddb7a493a7e4964308ccf38ddc01 100644 (file)
@@ -379,7 +379,7 @@ LIMIT 1";
    *
    */
   public static function checkFinancialTypeHasDeferred($params, $contributionID = NULL, $priceSetFields = NULL) {
-    if (!CRM_Contribute_BAO_Contribution::checkContributeSettings('deferred_revenue_enabled')) {
+    if (!Civi::settings()->get('deferred_revenue_enabled')) {
       return FALSE;
     }
     $recognitionDate = CRM_Utils_Array::value('revenue_recognition_date', $params);
index 3e1c01588ee3462f2092590f7907cdffe2428a4a..1ffafe2a33247fc78714b7d38f5156ac5cea8bfc 100644 (file)
@@ -312,7 +312,7 @@ class CRM_Member_Form_MembershipType extends CRM_Member_Form_MembershipConfig {
 
     $this->assign('membershipTypeId', $this->_id);
 
-    if (CRM_Contribute_BAO_Contribution::checkContributeSettings('deferred_revenue_enabled')) {
+    if (Civi::settings()->get('deferred_revenue_enabled')) {
       $deferredFinancialType = CRM_Financial_BAO_FinancialAccount::getDeferredFinancialType();
       $this->assign('deferredFinancialType', array_keys($deferredFinancialType));
     }
index 44505f9f462cfedca3b41617321f30815f4231d3..a53d26583f60c2c3560d721e3c393a728f75a706 100644 (file)
@@ -1003,7 +1003,7 @@ WHERE eft.entity_id = %1 AND ft.to_financial_account_id <> %2";
    * Test checkContributeSettings.
    */
   public function testCheckContributeSettings() {
-    $settings = CRM_Contribute_BAO_Contribution::checkContributeSettings('deferred_revenue_enabled');
+    $settings = Civi::settings()->get('deferred_revenue_enabled');
     $this->assertNull($settings);
     $params = array(
       'contribution_invoice_settings' => array(
@@ -1011,7 +1011,7 @@ WHERE eft.entity_id = %1 AND ft.to_financial_account_id <> %2";
       ),
     );
     $this->callAPISuccess('Setting', 'create', $params);
-    $settings = CRM_Contribute_BAO_Contribution::checkContributeSettings('deferred_revenue_enabled');
+    $settings = Civi::settings()->get('deferred_revenue_enabled');
     $this->assertEquals($settings, 1, 'Check for settings has failed');
   }