// CRM-16189
if (!empty($params['financial_type_id'])) {
- $isError = CRM_Financial_BAO_FinancialAccount::validateFinancialType($params['financial_type_id']);
- if ($isError) {
- throw new CRM_Core_Exception(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'));
- }
+ CRM_Financial_BAO_FinancialAccount::validateFinancialType($params['financial_type_id']);
}
$event = new CRM_Event_DAO_Event();
}
}
// CRM-16189
- $isError = CRM_Financial_BAO_FinancialAccount::validateFinancialType($values['financial_type_id']);
- 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');
+ try {
+ CRM_Financial_BAO_FinancialAccount::validateFinancialType($values['financial_type_id']);
+ }
+ catch (CRM_Core_Exception $e) {
+ $errors['financial_type_id'] = $e->getMessage();
}
return empty($errors) ? TRUE : $errors;
}
}
$deferredFinancialType = self::getDeferredFinancialType();
if (!array_key_exists($financialTypeId, $deferredFinancialType)) {
- return TRUE;
+ throw new CRM_Core_Exception(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 FALSE;
}
}
// CRM-16189
- $isError = CRM_Financial_BAO_FinancialAccount::validateFinancialType(
- CRM_Utils_Array::value('financial_type_id', $params)
- );
- if ($isError) {
- throw new CRM_Core_Exception(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'));
+ if (!empty($params['financial_type_id'])) {
+ CRM_Financial_BAO_FinancialAccount::validateFinancialType(
+ $params['financial_type_id']
+ );
}
// action is taken depending upon the mode
}
// CRM-16189
- $isError = CRM_Financial_BAO_FinancialAccount::validateFinancialType($params['financial_type_id']);
- 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');
+ try {
+ CRM_Financial_BAO_FinancialAccount::validateFinancialType($params['financial_type_id']);
+ }
+ catch (CRM_Core_Exception $e) {
+ $errors['financial_type_id'] = $e->getMessage();
}
return empty($errors) ? TRUE : $errors;
if (!$priceFieldID) {
$priceFieldID = CRM_Core_DAO::getFieldValue('CRM_Price_BAO_PriceFieldValue', $id, 'price_field_id');
}
- $isError = CRM_Financial_BAO_FinancialAccount::validateFinancialType(
- CRM_Utils_Array::value('financial_type_id', $params),
- $priceFieldID,
- 'PriceField'
- );
- if ($isError) {
- throw new CRM_Core_Exception(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'));
+ if (!empty($params['financial_type_id'])) {
+ CRM_Financial_BAO_FinancialAccount::validateFinancialType(
+ $params['financial_type_id'],
+ $priceFieldID,
+ 'PriceField'
+ );
}
if (!empty($params['is_default'])) {
$query = 'UPDATE civicrm_price_field_value SET is_default = 0 WHERE price_field_id = %1';
$priceSetID = CRM_Utils_Array::value('id', $params);
}
// CRM-16189
- if ($validatePriceSet) {
- $isError = CRM_Financial_BAO_FinancialAccount::validateFinancialType(
- CRM_Utils_Array::value('financial_type_id', $params),
+ if ($validatePriceSet && !empty($params['financial_type_id'])) {
+ CRM_Financial_BAO_FinancialAccount::validateFinancialType(
+ $params['financial_type_id'],
$priceSetID
);
- if ($isError) {
- throw new CRM_Core_Exception(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'));
- }
}
$priceSetBAO = new CRM_Price_BAO_PriceSet();
$priceSetBAO->copyValues($params);
}
else {
// CRM-16189
- $isError = CRM_Financial_BAO_FinancialAccount::validateFinancialType($fields['financial_type_id'], $form->_sid);
- 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');
+ try {
+ CRM_Financial_BAO_FinancialAccount::validateFinancialType($fields['financial_type_id'], $form->_sid);
+ }
+ catch (CRM_Core_Exception $e) {
+ $errors['financial_type_id'] = $e->getMessage();
}
}
}
$_flagOption = $_emptyRow = 0;
// CRM-16189
- $isError = CRM_Financial_BAO_FinancialAccount::validateFinancialType($fields['option_financial_type_id'][$index], $form->_fid, 'PriceField');
- if ($isError) {
- $errors["option_financial_type_id[{$index}]"] = 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');
+ try {
+ CRM_Financial_BAO_FinancialAccount::validateFinancialType($fields['option_financial_type_id'][$index], $form->_fid, 'PriceField');
+ }
+ catch(CRM_Core_Exception $e) {
+ $errors["option_financial_type_id[{$index}]"] = $e->getMessage();
}
}
$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');
+ try {
+ CRM_Financial_BAO_FinancialAccount::validateFinancialType($fields['financial_type_id'], $form->_fid, 'PriceField');
+ }
+ catch (CRM_Core_Exception $e) {
+ $errors['financial_type_id'] = $e->getMessage();
}
return empty($errors) ? TRUE : $errors;
}
&& (array_key_exists(CRM_Core_Component::getComponentID('CiviEvent'), $fields['extends'])
|| array_key_exists(CRM_Core_Component::getComponentID('CiviMember'), $fields['extends']))
) {
- $isError = CRM_Financial_BAO_FinancialAccount::validateFinancialType($fields['financial_type_id']);
- 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');
+ try {
+ CRM_Financial_BAO_FinancialAccount::validateFinancialType($fields['financial_type_id']);
+ }
+ catch (CRM_Core_Exception $e) {
+ $errors['financial_type_id'] = $e->getMessage();
}
}
return empty($errors) ? TRUE : $errors;