Merge pull request #8848 from JMAConsulting/CRM-16189-7
authorMonish Deb <monish.deb@webaccessglobal.com>
Tue, 20 Sep 2016 08:48:32 +0000 (14:18 +0530)
committerGitHub <noreply@github.com>
Tue, 20 Sep 2016 08:48:32 +0000 (14:18 +0530)
[ready-for-core-team-review]CRM-16189, freeze revenue recognition date if contribution is associated with participant and only membership

1  2 
CRM/Contribute/BAO/Contribution.php
CRM/Contribute/Form/Contribution.php

index 2da2df36f21d426e81f8a9f870f5de96fe997126,c4f44c0d1e8753b823ff8765f1835204e3945101..605ef432b2e14c60a8bcc05c5f3f0ef96170d0e7
@@@ -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);
      }
  
index f8f9baf8fdcdc3052f5239b16a87918e96780985,97b24e9ac8ecf23a8bc63e0870e10617880e18d6..a22163f37a0f48566e990e305562e56e59ef2b85
@@@ -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