CRM-16189, added code to validate financial type for contribution
authorPradeep Nayak <pradpnayak@gmail.com>
Wed, 15 Jun 2016 19:28:20 +0000 (00:58 +0530)
committerEdsel <edsel.lopez@jmaconsulting.biz>
Thu, 7 Jul 2016 10:11:06 +0000 (15:41 +0530)
----------------------------------------
* CRM-16189: Improve support for Accrual Method bookkeeping
  https://issues.civicrm.org/jira/browse/CRM-16189

Conflicts:
CRM/Contribute/Form/Contribution.php

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

index a6c6c0b4515ab462a9a98bc7926cb56f68b8b673..8516554d108463e0fe0f7e05b47238be54ac53ab 100644 (file)
@@ -177,6 +177,11 @@ class CRM_Contribute_BAO_Contribution extends CRM_Contribute_DAO_Contribution {
       $params['prevContribution'] = self::getValues(array('id' => $contributionID), CRM_Core_DAO::$_nullArray, CRM_Core_DAO::$_nullArray);
     }
 
+    // CRM-16189
+    $error = CRM_Financial_BAO_FinancialAccount::checkForValidFinancialType($params, $contributionID);
+    if ($error) {
+      throw new CRM_Core_Exception($error);
+    }
     if ($contributionID) {
       CRM_Utils_Hook::pre('edit', 'Contribution', $contributionID, $params);
     }
index 318b7f2290763bdeb1f7a22140a4eff0aab782c2..15b7fbedeb038eb602c68deffa20ac30dc47d82f 100644 (file)
@@ -1008,6 +1008,11 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP
     ) {
       $errors['revenue_recognition_date'] = ts('Month and Year are required field for Revenue Recognition.');
     }
+    // CRM-16189
+    $errorMessage = CRM_Financial_BAO_FinancialAccount::checkForValidFinancialType($fields, $self->_id, $self);
+    if ($errorMessage) {
+      $errors['financial_type_id'] = $errorMessage;
+    }
     $errors = array_merge($errors, $softErrors);
     return $errors;
   }