From: Pradeep Nayak Date: Tue, 28 May 2013 17:39:59 +0000 (+0530) Subject: -- CRM fixes for CRM-12470 X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=cf1d2db79f99cb3164e92c639fdb83104339215e;p=civicrm-core.git -- CRM fixes for CRM-12470 ---------------------------------------- * CRM-12470: Creating new financial type without AR account leads to unbalanced transactions http://issues.civicrm.org/jira/browse/CRM-12470 * CRM-12470-masterFixes: http://issues.civicrm.org/jira/browse/CRM-12470-masterFixes --- diff --git a/CRM/Financial/BAO/FinancialType.php b/CRM/Financial/BAO/FinancialType.php index 1fc0fe8ae8..197474f4d6 100644 --- a/CRM/Financial/BAO/FinancialType.php +++ b/CRM/Financial/BAO/FinancialType.php @@ -125,6 +125,9 @@ class CRM_Financial_BAO_FinancialType extends CRM_Financial_DAO_FinancialType { $financialType = new CRM_Financial_DAO_FinancialType( ); $financialType->id = $financialTypeId; $financialType->find(true); + // tables to ingore checks for financial_type_id + $ignoreTables = array('CRM_Financial_DAO_EntityFinancialAccount'); + //TODO: if (!$financialType->find(true)) { // ensure that we have no objects that have an FK to this financial type id TODO: that cannot be null @@ -132,14 +135,19 @@ class CRM_Financial_BAO_FinancialType extends CRM_Financial_DAO_FinancialType { if ($occurrences) { $tables = array(); foreach ($occurrences as $occurence) { - $tables[] = get_class($occurence); + $className = get_class($occurence); + if (!in_array($className, $ignoreTables)) { + $tables[] = $className; + } } - $message = ts('The following tables have an entry for this financial type: %1', array( '%1' => implode(', ', $tables) )); + if (!empty($tables)) { + $message = ts('The following tables have an entry for this financial type: %1', array('%1' => implode(', ', $tables))); - $errors = array(); - $errors['is_error'] = 1; - $errors['error_message'] = $message; - return $errors; + $errors = array(); + $errors['is_error'] = 1; + $errors['error_message'] = $message; + return $errors; + } } //delete from financial Type table