From a17bec97595f7362c33dc0b78be76edbb8cdd8cb Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Mon, 20 May 2019 10:09:59 +1200 Subject: [PATCH] dev/financial#54 check the correct place for deferred_revenut settings 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 | 4 ++-- CRM/Contribute/Form/Contribution.php | 2 +- CRM/Event/Form/ManageEvent/Fee.php | 2 +- CRM/Event/Form/Participant.php | 2 +- CRM/Event/Form/Registration/Confirm.php | 2 +- CRM/Financial/BAO/FinancialAccount.php | 2 +- CRM/Member/Form/MembershipType.php | 2 +- tests/phpunit/CRM/Contribute/BAO/ContributionTest.php | 4 ++-- 8 files changed, 10 insertions(+), 10 deletions(-) diff --git a/CRM/Contribute/BAO/Contribution.php b/CRM/Contribute/BAO/Contribution.php index 8f1fd8db46..2afb3597fc 100644 --- a/CRM/Contribute/BAO/Contribution.php +++ b/CRM/Contribute/BAO/Contribution.php @@ -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; diff --git a/CRM/Contribute/Form/Contribution.php b/CRM/Contribute/Form/Contribution.php index ab46198a0b..5258258aed 100644 --- a/CRM/Contribute/Form/Contribution.php +++ b/CRM/Contribute/Form/Contribution.php @@ -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(); diff --git a/CRM/Event/Form/ManageEvent/Fee.php b/CRM/Event/Form/ManageEvent/Fee.php index 3a02919e22..ddc1c2da06 100644 --- a/CRM/Event/Form/ManageEvent/Fee.php +++ b/CRM/Event/Form/ManageEvent/Fee.php @@ -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)); } diff --git a/CRM/Event/Form/Participant.php b/CRM/Event/Form/Participant.php index 0b0b31e0dc..3cd49af6c1 100644 --- a/CRM/Event/Form/Participant.php +++ b/CRM/Event/Form/Participant.php @@ -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)); diff --git a/CRM/Event/Form/Registration/Confirm.php b/CRM/Event/Form/Registration/Confirm.php index bc800a62a5..8bebdb1e6a 100644 --- a/CRM/Event/Form/Registration/Confirm.php +++ b/CRM/Event/Form/Registration/Confirm.php @@ -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( diff --git a/CRM/Financial/BAO/FinancialAccount.php b/CRM/Financial/BAO/FinancialAccount.php index 02ff4d9de8..c8f3357370 100644 --- a/CRM/Financial/BAO/FinancialAccount.php +++ b/CRM/Financial/BAO/FinancialAccount.php @@ -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); diff --git a/CRM/Member/Form/MembershipType.php b/CRM/Member/Form/MembershipType.php index 3e1c01588e..1ffafe2a33 100644 --- a/CRM/Member/Form/MembershipType.php +++ b/CRM/Member/Form/MembershipType.php @@ -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)); } diff --git a/tests/phpunit/CRM/Contribute/BAO/ContributionTest.php b/tests/phpunit/CRM/Contribute/BAO/ContributionTest.php index 44505f9f46..a53d26583f 100644 --- a/tests/phpunit/CRM/Contribute/BAO/ContributionTest.php +++ b/tests/phpunit/CRM/Contribute/BAO/ContributionTest.php @@ -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'); } -- 2.25.1