From: Pradeep Nayak Date: Wed, 15 Jun 2016 19:28:20 +0000 (+0530) Subject: CRM-16189, added code to validate financial type for contribution X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=3adac1594a88b982eb27318e020e37a792c4e056;p=civicrm-core.git CRM-16189, added code to validate financial type for contribution ---------------------------------------- * CRM-16189: Improve support for Accrual Method bookkeeping https://issues.civicrm.org/jira/browse/CRM-16189 Conflicts: CRM/Contribute/Form/Contribution.php --- diff --git a/CRM/Contribute/BAO/Contribution.php b/CRM/Contribute/BAO/Contribution.php index a6c6c0b451..8516554d10 100644 --- a/CRM/Contribute/BAO/Contribution.php +++ b/CRM/Contribute/BAO/Contribution.php @@ -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); } diff --git a/CRM/Contribute/Form/Contribution.php b/CRM/Contribute/Form/Contribution.php index 318b7f2290..15b7fbedeb 100644 --- a/CRM/Contribute/Form/Contribution.php +++ b/CRM/Contribute/Form/Contribution.php @@ -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; }