[ready-for-core-team-review]CRM-16189, Added checks to validate financial type to...
[civicrm-core.git] / CRM / Price / Form / Option.php
index a29cf32631ca13f9e126107af35cd6c23c931bb2..e61012232f10e9741267cc62a312eae581f24821 100644 (file)
@@ -285,7 +285,11 @@ class CRM_Price_Form_Option extends CRM_Core_Form {
     ) {
       $errors['count'] = ts('Participant count can not be greater than max participants.');
     }
-
+    // CRM-16189
+    $isError = CRM_Financial_BAO_FinancialAccount::validateFinancialType($fields['financial_type_id'], $form->_fid, 'PriceField');
+    if ($isError) {
+      $errors['financial_type_id'] = ts('Deferred revenue account is not configured for selected financial type. Please have an administrator set up the deferred revenue account at Administer > CiviContribute > Financial Accounts, then configure it for financial types at Administer > CiviContribution > Financial Types, Accounts');
+    }
     return empty($errors) ? TRUE : $errors;
   }