From: Monish Deb Date: Tue, 20 Sep 2016 08:48:32 +0000 (+0530) Subject: Merge pull request #8848 from JMAConsulting/CRM-16189-7 X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=7ba9f1d2c4dcd13fa8fe542728cd152eff860c0f;p=civicrm-core.git Merge pull request #8848 from JMAConsulting/CRM-16189-7 [ready-for-core-team-review]CRM-16189, freeze revenue recognition date if contribution is associated with participant and only membership --- 7ba9f1d2c4dcd13fa8fe542728cd152eff860c0f diff --cc CRM/Contribute/BAO/Contribution.php index 2da2df36f2,c4f44c0d1e..605ef432b2 --- a/CRM/Contribute/BAO/Contribution.php +++ b/CRM/Contribute/BAO/Contribution.php @@@ -188,9 -188,15 +188,15 @@@ class CRM_Contribute_BAO_Contribution e // CRM-16189 CRM_Financial_BAO_FinancialAccount::checkFinancialTypeHasDeferred($params, $contributionID); + if ($contributionID && !empty($params['revenue_recognition_date']) + && !($contributionStatus[$params['prevContribution']->contribution_status_id] == 'Pending') + && !self::allowUpdateRevenueRecognitionDate($contributionID) + ) { + unset($params['revenue_recognition_date']); + } - if (!isset($params['tax_amount']) && $setPrevContribution && (isset($params['total_amount']) || isset - ($params['financial_type_id']))) { + if (!isset($params['tax_amount']) && $setPrevContribution && (isset($params['total_amount']) || + isset($params['financial_type_id']))) { $params = CRM_Contribute_BAO_Contribution::checkTaxAmount($params); } diff --cc CRM/Contribute/Form/Contribution.php index f8f9baf8fd,97b24e9ac8..a22163f37a --- a/CRM/Contribute/Form/Contribution.php +++ b/CRM/Contribute/Form/Contribution.php @@@ -755,16 -749,12 +755,19 @@@ class CRM_Contribute_Form_Contribution FALSE ); + $currencyFreeze = FALSE; + if (!empty($this->_payNow) && ($this->_action & CRM_Core_Action::UPDATE)) { + $statusElement->freeze(); + $currencyFreeze = TRUE; + $attributes['total_amount']['readonly'] = TRUE; + } + // CRM-16189, add Revenue Recognition Date if (CRM_Contribute_BAO_Contribution::checkContributeSettings('deferred_revenue_enabled')) { - $this->add('date', 'revenue_recognition_date', ts('Revenue Recognition Date'), CRM_Core_SelectValues::date(NULL, 'M Y', NULL, 5)); + $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(); + } } // add various dates