Refactored out of CRM_Core_PseudoConstant: accountOptionValues(). CRM-12464
authorAllen Shaw <allen@emphanos.com>
Fri, 3 May 2013 04:43:48 +0000 (21:43 -0700)
committerColeman Watts <coleman@civicrm.org>
Thu, 30 May 2013 05:13:54 +0000 (22:13 -0700)
----------------------------------------
* CRM-12464: Search improvements in 4.4
  http://issues.civicrm.org/jira/browse/CRM-12464

----------------------------------------
* CRM-12464:
  http://issues.civicrm.org/jira/browse/CRM-12464
* CRM-12464::
  http://issues.civicrm.org/jira/browse/CRM-12464:

28 files changed:
CRM/Admin/Form/OptionValue.php
CRM/Admin/Form/Options.php
CRM/Admin/Form/PaymentProcessor.php
CRM/Batch/BAO/Batch.php
CRM/Batch/Form/Entry.php
CRM/Contribute/BAO/Contribution.php
CRM/Core/BAO/FinancialTrxn.php
CRM/Event/BAO/Participant.php
CRM/Financial/BAO/FinancialAccount.php
CRM/Financial/BAO/FinancialItem.php
CRM/Financial/BAO/FinancialType.php
CRM/Financial/BAO/FinancialTypeAccount.php
CRM/Financial/BAO/PaymentProcessor.php
CRM/Financial/Form/Export.php
CRM/Financial/Form/FinancialAccount.php
CRM/Financial/Form/FinancialBatch.php
CRM/Financial/Form/FinancialTypeAccount.php
CRM/Financial/Page/AJAX.php
CRM/Financial/Page/FinancialAccount.php
CRM/Financial/Page/FinancialTypeAccount.php
CRM/Upgrade/Incremental/php/FourThree.php
tests/phpunit/CRM/Core/PseudoConstantTest.php
tests/phpunit/CRM/Financial/BAO/FinancialTypeAccountTest.php
tests/phpunit/api/v3/ContributionTest.php
xml/schema/Financial/EntityFinancialAccount.xml
xml/schema/Financial/FinancialAccount.xml
xml/schema/Financial/FinancialItem.xml
xml/schema/Financial/FinancialTrxn.xml

index 9cd7e54a4f1acef4391ec7c2ea470ed818970304..5aab18f425822b28a661068317dc3724c4f73329 100644 (file)
@@ -162,7 +162,7 @@ class CRM_Admin_Form_OptionValue extends CRM_Admin_Form {
 
     // CRM-11516
     if ($this->_gName == 'payment_instrument') {
-      $accountType = CRM_Core_PseudoConstant::accountOptionValues('financial_account_type', NULL, " AND v.name = 'Asset' ");
+      $accountType = CRM_Core_PseudoConstant::get('CRM_Financial_DAO_FinancialAccount', 'financial_account_type_id', array('condition' => " AND v.name = 'Asset' "));
       $financialAccount = CRM_Contribute_PseudoConstant::financialAccount(NULL, key($accountType));
       
       $this->add('select', 'financial_account_id', ts('Financial Account'), 
@@ -272,7 +272,7 @@ class CRM_Admin_Form_OptionValue extends CRM_Admin_Form {
       $optionValue = CRM_Core_BAO_OptionValue::add($params, $ids);
       // CRM-11516
       if (CRM_Utils_Array::value('financial_account_id', $params)) {
-        $relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Asset Account is' "));
+        $relationTypeId = key(CRM_Core_PseudoConstant::get('CRM_Financial_DAO_EntityFinancialAccount', 'account_relationship', array('condition' => " AND v.name LIKE 'Asset Account is' ")));
         $params = array(
           'entity_table' => 'civicrm_option_value',
           'entity_id' => $optionValue->id,
index 32ae6c12f8865e0757c7ab5f9d2350a19e9c2ff5..9924d0cca0daa1e18bae5aceafa8c8d935177337 100644 (file)
@@ -190,7 +190,7 @@ class CRM_Admin_Form_Options extends CRM_Admin_Form {
     }
     // CRM-11516
     if ($this->_gName == 'payment_instrument') {
-      $accountType = CRM_Core_PseudoConstant::accountOptionValues('financial_account_type', NULL, " AND v.name = 'Asset' ");
+      $accountType = CRM_Core_PseudoConstant::get('CRM_Financial_DAO_FinancialAccount', 'financial_account_type_id', array('condition' => " AND v.name = 'Asset' "));
       $financialAccount = CRM_Contribute_PseudoConstant::financialAccount(NULL, key($accountType));
       
       $this->add('select', 'financial_account_id', ts('Financial Account'), 
@@ -405,7 +405,7 @@ class CRM_Admin_Form_Options extends CRM_Admin_Form {
       
       // CRM-11516
       if (CRM_Utils_Array::value('financial_account_id', $params)) {
-        $relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Asset Account is' "));
+        $relationTypeId = key(CRM_Core_PseudoConstant::get('CRM_Financial_DAO_EntityFinancialAccount', 'account_relationship', array('condition' => " AND v.name LIKE 'Asset Account is' ")));
         $params = array(
           'entity_table' => 'civicrm_option_value',
           'entity_id' => $optionValue->id,
index bc34146d0e4cd0573aa80ed227e85356fb346946..7a24c53f20c43ea8219c5714980a31eb34c4cc18 100644 (file)
@@ -189,7 +189,7 @@ class CRM_Admin_Form_PaymentProcessor extends CRM_Admin_Form {
     );
 
     // Financial Account of account type asset CRM-11515
-    $accountType = CRM_Core_PseudoConstant::accountOptionValues('financial_account_type', NULL, " AND v.name = 'Asset' ");
+    $accountType = CRM_Core_PseudoConstant::get('CRM_Financial_DAO_FinancialAccount', 'financial_account_type_id', array('condition' => " AND v.name = 'Asset' "));
     $financialAccount = CRM_Contribute_PseudoConstant::financialAccount(NULL, key($accountType));
     if ($fcount = count($financialAccount)) {
       $this->assign('financialAccount', $fcount);
@@ -380,7 +380,7 @@ class CRM_Admin_Form_PaymentProcessor extends CRM_Admin_Form {
     
     //CRM-11515
     
-    $relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Asset Account is' "));
+    $relationTypeId = key(CRM_Core_PseudoConstant::get('CRM_Financial_DAO_EntityFinancialAccount', 'account_relationship', array('condition' => " AND v.name LIKE 'Asset Account is' ")));
     $params = array(
       'entity_table' => 'civicrm_payment_processor',
       'entity_id' => $dao->id,
index 706e4b93f11777068e40c3354ce7ed3325b472b3..040794be27f2f68256f1db5c24f90c70aade1e47 100644 (file)
@@ -596,7 +596,7 @@ class CRM_Batch_BAO_Batch extends CRM_Batch_DAO_Batch {
   }
 
   static function closeReOpen($batchIds = array(), $status) {
-    $batchStatus = CRM_Core_PseudoConstant::accountOptionValues( 'batch_status' );
+    $batchStatus = CRM_Core_PseudoConstant::get('CRM_Financial_DAO_FinancialItem', 'status_id');
     $params['status_id'] = CRM_Utils_Array::key( $status, $batchStatus );
     $session = CRM_Core_Session::singleton( );
     $params['modified_date'] = date('YmdHis');
index 2bdd049f2a8822e50fd8a72223833070c919916d..ecf467447f714f748439ee7b808f8804f9317dff 100644 (file)
@@ -366,8 +366,6 @@ class CRM_Batch_Form_Entry extends CRM_Core_Form {
     $this->_priceSet = current(CRM_Price_BAO_Set::getSetDetail($priceSetId));
     $fieldID = key($this->_priceSet['fields']);
 
-    $assetRelation = key(CRM_CORE_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Asset Account is' "));
-
     if (isset($params['field'])) {
       foreach ($params['field'] as $key => $value) {
         // if contact is not selected we should skip the row
index 6e56b0c7636e518662afed8742acd34fec0ce495..aa589ef12e7e641c864ddac9090da490764a3faa 100644 (file)
@@ -2505,7 +2505,7 @@ WHERE  contribution_id = %1 ";
       !(CRM_Utils_Array::value('contribution_status_id', $params) == array_search('Pending', $contributionStatuses) && !$params['contribution']->is_pay_later)) {
       $skipRecords = TRUE;
       if (CRM_Utils_Array::value('contribution_status_id', $params) == array_search('Pending', $contributionStatuses)) {
-        $relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Accounts Receivable Account is' "));
+        $relationTypeId = key(CRM_Core_PseudoConstant::get('CRM_Financial_DAO_EntityFinancialAccount', 'account_relationship', array('condition' => " AND v.name LIKE 'Accounts Receivable Account is' ")));
         $params['to_financial_account_id'] = CRM_Contribute_PseudoConstant::financialAccountType($params['financial_type_id'], $relationTypeId);
       }
       elseif (CRM_Utils_Array::value('payment_processor', $params)) {
@@ -2597,7 +2597,7 @@ WHERE  contribution_id = %1 ";
         //if financial type is changed
         if (CRM_Utils_Array::value('financial_type_id', $params) &&
           $params['contribution']->financial_type_id != $params['prevContribution']->financial_type_id) {
-          $incomeTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Income Account is' "));
+          $incomeTypeId = key(CRM_Core_PseudoConstant::get('CRM_Financial_DAO_EntityFinancialAccount', 'account_relationship', array('condition' => " AND v.name LIKE 'Income Account is' ")));
           $oldFinancialAccount = CRM_Contribute_PseudoConstant::financialAccountType($params['prevContribution']->financial_type_id, $incomeTypeId);
           $newFinancialAccount = CRM_Contribute_PseudoConstant::financialAccountType($params['financial_type_id'], $incomeTypeId);
           if ($oldFinancialAccount != $newFinancialAccount) {
@@ -2689,8 +2689,7 @@ WHERE  contribution_id = %1 ";
           $params['trxnParams']['to_financial_account_id'] = NULL;
           $params['trxnParams']['total_amount'] = - $params['total_amount'];
         }
-        $relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL,
-          " AND v.name LIKE 'Accounts Receivable Account is' "));
+        $relationTypeId = key(CRM_Core_PseudoConstant::get('CRM_Financial_DAO_EntityFinancialAccount', 'account_relationship', array('condition' => " AND v.name LIKE 'Accounts Receivable Account is' ")));
         $params['trxnParams']['from_financial_account_id'] = CRM_Contribute_PseudoConstant::financialAccountType(
           $financialTypeID, $relationTypeId);
       }
@@ -2700,7 +2699,7 @@ WHERE  contribution_id = %1 ";
       if ($params['prevContribution']->payment_instrument_id != null
         && $params['prevContribution']->contribution_status_id == array_search('Pending', $contributionStatus)
         && $params['contribution']->contribution_status_id == array_search('Pending', $contributionStatus)) {
-        $relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Accounts Receivable Account is' "));
+        $relationTypeId = key(CRM_Core_PseudoConstant::get('CRM_Financial_DAO_EntityFinancialAccount', 'account_relationship', array('condition' => " AND v.name LIKE 'Accounts Receivable Account is' ")));
         $params['trxnParams']['from_financial_account_id'] = CRM_Contribute_PseudoConstant::financialAccountType($params['financial_type_id'], $relationTypeId);
       }
       elseif ($params['prevContribution']->payment_instrument_id != null) {
index 95a675df667c3d8ec978141dc9b58abcebdcacb5..90827d7d33dc3af5eb2c0b9bc1a472ea5134f0ab 100644 (file)
@@ -286,7 +286,7 @@ WHERE ceft.entity_id = %1";
     if (CRM_Utils_Array::value('cost', $params)) {
       $contributionStatuses = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
       $financialAccountType = CRM_Contribute_PseudoConstant::financialAccountType($params['financial_type_id']);
-      $accountRelationship = CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND label IN ('Premiums Inventory Account is', 'Cost of Sales Account is')");
+      $accountRelationship = CRM_Core_PseudoConstant::get('CRM_Financial_DAO_EntityFinancialAccount', 'account_relationship', array('condition' => " AND label IN ('Premiums Inventory Account is', 'Cost of Sales Account is')"));
       $toFinancialAccount = CRM_Utils_Array::value('isDeleted', $params) ? 'Premiums Inventory Account is' : 'Cost of Sales Account is';
       $fromFinancialAccount = CRM_Utils_Array::value('isDeleted', $params) ? 'Cost of Sales Account is': 'Premiums Inventory Account is';
       $accountRelationship = array_flip($accountRelationship);
@@ -329,7 +329,7 @@ WHERE ceft.entity_id = %1";
    */
 
   static function recordFees($params) {
-    $expenseTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Expense Account is' "));
+    $expenseTypeId = key(CRM_Core_PseudoConstant::get('CRM_Financial_DAO_EntityFinancialAccount', 'account_relationship', array('condition' => " AND v.name LIKE 'Expense Account is' ")));
     $domainId = CRM_Core_Config::domainID();
     $amount = 0;
     if (CRM_Utils_Array::value('prevContribution', $params)) {
index 134e56e3e8cbb1c19286ea5a7c39601a11eca18f..a0c77f3b80a7de04bec9afca1c0c339487f53036 100644 (file)
@@ -1745,7 +1745,7 @@ WHERE cpf.price_set_id = %1 AND cpfv.label LIKE %2";
       $params = array(1 => array($priceSetId, 'Integer'),
         2 => array($feeLevel, 'String'));
       $mainAmount = CRM_Core_DAO::singleValueQuery($query, $params);
-      $relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Discounts Account is' "));
+      $relationTypeId = key(CRM_Core_PseudoConstant::get('CRM_Financial_DAO_EntityFinancialAccount', 'account_relationship', array('condition' => " AND v.name LIKE 'Discounts Account is' ")));
       $contributionParams['trxnParams']['from_financial_account_id'] = CRM_Contribute_PseudoConstant::financialAccountType(
         $contributionParams['contribution']->financial_type_id, $relationTypeId);
       if (CRM_Utils_Array::value('from_financial_account_id', $contributionParams['trxnParams'])) {
index 9c53bf618edb396ba74ea74326f507d9cdd7b7d3..dec66f2ee9b2396ca86e009fca1526519eccf6e6 100644 (file)
@@ -159,7 +159,7 @@ class CRM_Financial_BAO_FinancialAccount extends CRM_Financial_DAO_FinancialAcco
    * @static
    */
   static function getAccountingCode($financialTypeId) {
-    $relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Income Account is' "));
+    $relationTypeId = key(CRM_Core_PseudoConstant::get('CRM_Financial_DAO_EntityFinancialAccount', 'account_relationship', array('condition' => " AND v.name LIKE 'Income Account is' ")));
     $query = "SELECT cfa.accounting_code
 FROM civicrm_financial_type cft
 LEFT JOIN civicrm_entity_financial_account cefa ON cefa.entity_id = cft.id AND cefa.entity_table = 'civicrm_financial_type'
index 6db9134a47b2f0a5fc3c6af64d822f8330360138..76d1fff87ba333a4aaf153731a2ad59929eb31cb 100644 (file)
@@ -78,7 +78,7 @@ class CRM_Financial_BAO_FinancialItem extends CRM_Financial_DAO_FinancialItem {
    */
   static function add($lineItem, $contribution) {
     $contributionStatuses = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
-    $financialItemStatus = CRM_Core_PseudoConstant::accountOptionValues('financial_item_status');
+    $financialItemStatus = CRM_Core_PseudoConstant::get('CRM_Financial_DAO_FinancialItem', 'status_id');
     if ($contribution->contribution_status_id == array_search('Completed', $contributionStatuses)) {
       $itemStatus = array_search('Paid', $financialItemStatus);
     }
index 197474f4d6163517e03a04a243a26cf15afc3f59..f90af7732d00d1254252e0fbcf056cd618d5e244 100644 (file)
@@ -171,7 +171,7 @@ class CRM_Financial_BAO_FinancialType extends CRM_Financial_DAO_FinancialType {
     // Financial Type
     $financialType = CRM_Contribute_PseudoConstant::financialType();
     $revenueFinancialType = array();
-    $relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Income Account is' "));
+    $relationTypeId = key(CRM_Core_PseudoConstant::get('CRM_Financial_DAO_EntityFinancialAccount', 'account_relationship', array('condition' => " AND v.name LIKE 'Income Account is' ")));
     CRM_Core_PseudoConstant::populate( 
       $revenueFinancialType,
       'CRM_Financial_DAO_EntityFinancialAccount',
index d4e74c0f6cf4bfafc9e21adc2d5f68cc9e0585a0..e542d00161f7d4ca3dec90a06ade4e11a3c33fe2 100644 (file)
@@ -112,7 +112,7 @@ class CRM_Financial_BAO_FinancialTypeAccount extends CRM_Financial_DAO_EntityFin
   static function del($financialTypeAccountId, $accountId = null) {
     //checking if financial type is present
     $check = false;
-    $relationValues = CRM_Core_PseudoConstant::accountOptionValues('account_relationship');
+    $relationValues = CRM_Core_PseudoConstant::get('CRM_Financial_DAO_EntityFinancialAccount', 'account_relationship');
 
     $financialTypeId = CRM_Core_DAO::getFieldValue( 'CRM_Financial_DAO_EntityFinancialAccount', $financialTypeAccountId, 'entity_id' );
     //check dependencies
index e536683819ad78b4c8bb40251688306c51fe9ddd..2e3da2a8af4dda31d9d55a7263ecc7679b1a81a2 100644 (file)
@@ -69,7 +69,7 @@ class CRM_Financial_BAO_PaymentProcessor extends CRM_Financial_DAO_PaymentProces
     // CRM-11826, add entry in civicrm_entity_financial_account
     // if financial_account_id is not NULL
     if (CRM_Utils_Array::value('financial_account_id', $params)) {
-      $relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Asset Account is' "));
+      $relationTypeId = key(CRM_Core_PseudoConstant::get('CRM_Financial_DAO_EntityFinancialAccount', 'account_relationship', array('condition' => " AND v.name LIKE 'Asset Account is' ")));
       $values = array(
         'entity_table' => 'civicrm_payment_processor',
         'entity_id' => $processor->id,
index 99a4cca31447d5a4e31e729a98b50dfba29784f8..b9b989a10aceee175fba70a3bb439cf78805b660 100644 (file)
@@ -95,7 +95,7 @@ class CRM_Financial_Form_Export extends CRM_Core_Form {
       $this->_batchIds = $this->_id;
     }
 
-    $allBatchStatus = CRM_Core_PseudoConstant::accountOptionValues('batch_status');
+    $allBatchStatus = CRM_Core_PseudoConstant::get('CRM_Financial_DAO_FinancialItem', 'status_id');
     $this->_exportStatusId = CRM_Utils_Array::key('Exported', $allBatchStatus);
 
     //check if batch status is valid, do not allow exported batches to export again
index c418a31580c99f6fc83732a0c9917f0ec79fef5a..a970104d97e0cf1df7d8949ac0bb0d3d312fd640 100644 (file)
@@ -114,7 +114,7 @@ class CRM_Financial_Form_FinancialAccount extends CRM_Contribute_Form {
       $element->freeze();
     }
 
-    $financialAccountType = CRM_Core_PseudoConstant::accountOptionValues('financial_account_type');
+    $financialAccountType = CRM_Core_PseudoConstant::get('CRM_Financial_DAO_FinancialAccount', 'financial_account_type_id');
     if (!empty($financialAccountType)) {
       $element = $this->add('select', 'financial_account_type_id', ts('Financial Account Type'),
         array('' => '- select -') + $financialAccountType, TRUE);
index a06021dcc9721cdc9eca67929364f013b2bda5c0..48da6bebe58673c37133bb993ac78f0fb3c8d25d 100644 (file)
@@ -121,7 +121,7 @@ class CRM_Financial_Form_FinancialBatch extends CRM_Contribute_Form {
     );
 
     if ($this->_action & CRM_Core_Action::UPDATE && $this->_id) {
-      $batchStatus = CRM_Core_PseudoConstant::accountOptionValues('batch_status');
+      $batchStatus = CRM_Core_PseudoConstant::get('CRM_Financial_DAO_FinancialItem', 'status_id');
 
       //unset exported status
       $exportedStatusId = CRM_Utils_Array::key('Exported', $batchStatus );
@@ -210,7 +210,7 @@ class CRM_Financial_Form_FinancialBatch extends CRM_Contribute_Form {
     $session = CRM_Core_Session::singleton();
     $ids = array();
     $params = $this->exportValues();
-    $batchStatus = CRM_Core_PseudoConstant::accountOptionValues('batch_status');
+    $batchStatus = CRM_Core_PseudoConstant::get('CRM_Financial_DAO_FinancialItem', 'status_id');
     if ($this->_id) {
       $ids['batchID'] = $this->_id;
       $params['id'] = $this->_id;
index 28644ffd4f7a5abf990fd01f5243be610bc15f3f..ca03b6d74846c1fd2d46180911d31364548ed2bf 100644 (file)
@@ -162,7 +162,7 @@ class CRM_Financial_Form_FinancialTypeAccount extends CRM_Contribute_Form {
       //hidden field to catch the field id in profile
       $this->add('hidden', 'account_type_id', $this->_id);
     }
-    $AccountTypeRelationship = CRM_Core_PseudoConstant::accountOptionValues('account_relationship');
+    $AccountTypeRelationship = CRM_Core_PseudoConstant::get('CRM_Financial_DAO_EntityFinancialAccount', 'account_relationship');
     if (!empty($AccountTypeRelationship)) {
       $element = $this->add('select',
         'account_relationship',
@@ -255,8 +255,7 @@ class CRM_Financial_Form_FinancialTypeAccount extends CRM_Contribute_Form {
     $errorMsg = array();
     $errorFlag = FALSE;
     if ($self->_action == CRM_Core_Action::DELETE) {
-      $groupName = 'account_relationship';
-      $relationValues = CRM_Core_PseudoConstant::accountOptionValues($groupName);
+      $relationValues = CRM_Core_PseudoConstant::get('CRM_Financial_DAO_EntityFinancialAccount', 'account_relationship');
       if (CRM_Utils_Array::value('financial_account_id', $values) != 'select') {
         if ($relationValues[$values['account_relationship']] == 'Premiums Inventory Account is' || $relationValues[$values['account_relationship']] == 'Cost of Sales Account is') {
           $premiumsProduct = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_PremiumsProduct', $values['financial_type_id'], 'product_id', 'financial_type_id');
index 5913e692aa590de54489fdcd3af456b45b6c12c6..35ac51084c0201504e6fb4c95a3e289d59d40e6d 100644 (file)
@@ -98,7 +98,7 @@ class CRM_Financial_Page_AJAX {
     }
 
     if ($_GET['_value'] == 'select') {
-      $result = CRM_Core_PseudoConstant::accountOptionValues('account_relationship');
+      $result = CRM_Core_PseudoConstant::get('CRM_Financial_DAO_EntityFinancialAccount', 'account_relationship');
     }
     else {
       $financialAccountType = array(
@@ -108,7 +108,7 @@ class CRM_Financial_Page_AJAX {
         '4' => array(7), //cost of sales
       );
       $financialAccountTypeId = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialAccount', $_GET['_value'], 'financial_account_type_id');
-      $result = CRM_Core_PseudoConstant::accountOptionValues('account_relationship');
+      $result = CRM_Core_PseudoConstant::get('CRM_Financial_DAO_EntityFinancialAccount', 'account_relationship');
     }
 
     $elements = array(
@@ -216,7 +216,7 @@ class CRM_Financial_Page_AJAX {
           case 'reopen':
             $status = $op == 'close' ? 'Closed' : 'Open';
             $ids['batchID'] = $recordID;
-            $batchStatus = CRM_Core_PseudoConstant::accountOptionValues('batch_status');
+            $batchStatus = CRM_Core_PseudoConstant::get('CRM_Financial_DAO_FinancialItem', 'status_id');
             $params['status_id'] = CRM_Utils_Array::key($status, $batchStatus);
             $session = CRM_Core_Session::singleton();
             $params['modified_date'] = date('YmdHis');
index 5581502b3d5851eee9eea319f138a7813d92e8da..2f2e3eb54121b01fafcb23d3124681dacfcf3fca 100644 (file)
@@ -133,7 +133,7 @@ class CRM_Financial_Page_FinancialAccount extends CRM_Core_Page_Basic {
     $dao = new CRM_Financial_DAO_FinancialAccount();
     $dao->orderBy('financial_account_type_id, name');
     $dao->find();
-    $financialAccountType = CRM_Core_PseudoConstant::accountOptionValues('financial_account_type');
+    $financialAccountType = CRM_Core_PseudoConstant::get('CRM_Financial_DAO_FinancialAccount', 'financial_account_type_id');
 
     while ($dao->fetch()) {
       $contributionType[$dao->id] = array();
index ac1685f68a09b5f7dc34edb30da8855617815e01..82f1e78e5cd958727b172e837a5bb78ec160eddd 100644 (file)
@@ -137,8 +137,8 @@ class CRM_Financial_Page_FinancialTypeAccount extends CRM_Core_Page {
       $relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Accounts Receivable Account is' "));
       $this->_title = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialType', $this->_aid, 'name');
       CRM_Utils_System::setTitle($this->_title .' - '.ts( 'Assigned Financial Accounts'));
-      $financialAccountType = CRM_Core_PseudoConstant::accountOptionValues('financial_account_type');
-      $accountRelationship = CRM_Core_PseudoConstant::accountOptionValues('account_relationship');
+      $financialAccountType = CRM_Core_PseudoConstant::get('CRM_Financial_DAO_FinancialAccount', 'financial_account_type_id');
+      $accountRelationship = CRM_Core_PseudoConstant::get('CRM_Financial_DAO_EntityFinancialAccount', 'account_relationship');
       $dao->copyValues($params);
       $dao->find();
       while ($dao->fetch()) {
index 29798f0b09027e9913e6c680473db55a8caeabdd..fef9495b363722042f8a3c3ae86b08d52ea28ba7 100644 (file)
@@ -390,7 +390,7 @@ AND       ceft.entity_table = 'civicrm_contribution'
       3 => array($cancelledStatus, 'Integer')
     );
 
-    $accountType = key(CRM_Core_PseudoConstant::accountOptionValues('financial_account_type', NULL, " AND v.name = 'Asset' "));
+    $accountType = key(CRM_Core_PseudoConstant::get('CRM_Financial_DAO_FinancialAccount', 'financial_account_type_id', array('condition' => " AND v.name = 'Asset' ")));
     $query = "
 SELECT id
 FROM   civicrm_financial_account
@@ -399,14 +399,14 @@ AND    financial_account_type_id = {$accountType}
 ";
     $financialAccountId = CRM_Core_DAO::singleValueQuery($query);
 
-    $accountRelationsips = CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL);
+    $accountRelationsips = CRM_Core_PseudoConstant::get('CRM_Financial_DAO_EntityFinancialAccount', 'account_relationship');
 
     $accountsReceivableAccount = array_search('Accounts Receivable Account is', $accountRelationsips);
     $incomeAccountIs = array_search('Income Account is', $accountRelationsips);
     $assetAccountIs = array_search('Asset Account is', $accountRelationsips);
     $expenseAccountIs = array_search('Expense Account is', $accountRelationsips);
 
-    $financialItemStatus = CRM_Core_PseudoConstant::accountOptionValues('financial_item_status');
+    $financialItemStatus = CRM_Core_PseudoConstant::get('CRM_Financial_DAO_FinancialItem', 'status_id');
     $unpaidStatus = array_search('Unpaid', $financialItemStatus);
     $paidStatus = array_search('Paid', $financialItemStatus);
 
index 6e56febaff677982a03160b42460a81a2a49c806..e47eacfc06340d358c0696963e162e2b28fa302a 100644 (file)
@@ -68,6 +68,46 @@ class CRM_Core_PseudoConstantTest extends CiviUnitTestCase {
      * - max: integer (default = 10) maximum number of option values expected.
      */
     $fields = array(
+      'CRM_Financial_DAO_EntityFinancialAccount' => array(
+        array(
+          'fieldName' => 'financial_account_id',
+          'sample' => 'Member Dues',
+          'max' => 15,
+        ),
+        array(
+          'fieldName' => 'account_relationship',
+          'sample' => 'Income Account is',
+        ),
+      ),
+      'CRM_Financial_DAO_FinancialItem' => array(
+        array(
+          'fieldName' => 'status_id',
+          'sample' => 'Partially paid',
+        ),
+        array(
+          'fieldName' => 'financial_account_id',
+          'sample' => 'Accounts Receivable',
+          'max' => 15,
+        ),
+      ),
+      'CRM_Financial_DAO_FinancialTrxn' => array(
+        array(
+          'fieldName' => 'from_financial_account_id',
+          'sample' => 'Accounts Receivable',
+          'max' => 15,
+        ),
+        array(
+          'fieldName' => 'to_financial_account_id',
+          'sample' => 'Accounts Receivable',
+          'max' => 15,
+        ),
+      ),
+      'CRM_Financial_DAO_FinancialAccount' => array(
+        array(
+          'fieldName' => 'financial_account_type_id',
+          'sample' => 'Cost of Sales',
+        ),
+      ),
       'CRM_Event_DAO_Participant' => array(
         array(
           'fieldName' => 'fee_currency',
index f889bdc9a8ea967aae1fe42102398efb30a49153..3ade5e6b3e559d73ecb8a1389dc86aacd13514a1 100755 (executable)
@@ -58,7 +58,7 @@ class CRM_Financial_BAO_FinancialTypeAccountTest extends CiviUnitTestCase {
     $financialAccount = CRM_Financial_BAO_FinancialAccount::add($params, $ids);
     $params['name'] = 'test_financialType1';
     $financialType = CRM_Financial_BAO_FinancialType::add($params, $ids);
-    $relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Income Account is' "));
+    $relationTypeId = key(CRM_Core_PseudoConstant::get('CRM_Financial_DAO_EntityFinancialAccount', 'account_relationship', array('condition' => " AND v.name LIKE 'Income Account is' ")));
     $financialParams = array(
       'entity_table' => 'civicrm_financial_type',
       'entity_id' => $financialType->id,
@@ -93,7 +93,7 @@ class CRM_Financial_BAO_FinancialTypeAccountTest extends CiviUnitTestCase {
     $financialAccount = CRM_Financial_BAO_FinancialAccount::add($params, $ids);
     $params['name'] = 'test_financialType2';
     $financialType = CRM_Financial_BAO_FinancialType::add($params, $ids);
-    $relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Expense Account is' "));
+    $relationTypeId = key(CRM_Core_PseudoConstant::get('CRM_Financial_DAO_EntityFinancialAccount', 'account_relationship', array('condition' => " AND v.name LIKE 'Expense Account is' ")));
     $financialParams = array(
       'entity_table' => 'civicrm_financial_type',
       'entity_id' => $financialType->id,
@@ -121,7 +121,7 @@ class CRM_Financial_BAO_FinancialTypeAccountTest extends CiviUnitTestCase {
     $financialAccount = CRM_Financial_BAO_FinancialAccount::add($params, $ids);
     $params['name'] = 'test_financialType3';
     $financialType = CRM_Financial_BAO_FinancialType::add($params, $ids);
-    $relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Asset Account is' "));
+    $relationTypeId = key(CRM_Core_PseudoConstant::get('CRM_Financial_DAO_EntityFinancialAccount', 'account_relationship', array('condition' => " AND v.name LIKE 'Asset Account is' ")));
     $financialParams = array(
       'entity_table' => 'civicrm_financial_type',
       'entity_id' => $financialType->id,
@@ -182,7 +182,7 @@ class CRM_Financial_BAO_FinancialTypeAccountTest extends CiviUnitTestCase {
       'value' => $paymentInstrumentValue,
     );
     $optionValue = CRM_Core_BAO_OptionValue::retrieve($optionParams, $defaults);
-    $relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Asset Account is' "));
+    $relationTypeId = key(CRM_Core_PseudoConstant::get('CRM_Financial_DAO_EntityFinancialAccount', 'account_relationship', array('condition' => " AND v.name LIKE 'Asset Account is' ")));
     $financialParams = array(
       'entity_table' => 'civicrm_option_value',
       'entity_id' => $optionValue->id,
index 3ab0882576cd68976920040ec7997da454c9aba6..a2a69e789e9e2f4c55beac1ae674c9a8119ff46d 100644 (file)
@@ -1525,7 +1525,7 @@ class api_v3_ContributionTest extends CiviUnitTestCase {
      'id' => $trxn['financial_trxn_id'],
    );
    if ($context == 'payLater') {
-     $relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Accounts Receivable Account is' "));
+     $relationTypeId = key(CRM_Core_PseudoConstant::get('CRM_Financial_DAO_EntityFinancialAccount', 'account_relationship', array('condition' => " AND v.name LIKE 'Accounts Receivable Account is' ")));
      $compareParams = array(
        'status_id' => 1,
        'from_financial_account_id' => CRM_Contribute_PseudoConstant::financialAccountType($contribution['financial_type_id'], $relationTypeId),
@@ -1589,7 +1589,7 @@ class api_v3_ContributionTest extends CiviUnitTestCase {
      'version' => 3,
 );
    $optionValue = civicrm_api('option_value', 'create', $optionParams);
-   $relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Asset Account is' "));
+   $relationTypeId = key(CRM_Core_PseudoConstant::get('CRM_Financial_DAO_EntityFinancialAccount', 'account_relationship', array('condition' => " AND v.name LIKE 'Asset Account is' ")));
    $financialParams = array(
      'entity_table' => 'civicrm_option_value',
      'entity_id' => $optionValue['id'],
index edd95ff7984ef917937f6c61d63816ba9d6e5a55..e9273bb442f83430a5f665580baf9a84842e3a05 100755 (executable)
@@ -45,6 +45,9 @@
     <required>true</required>
     <add>4.3</add>  
     <comment>FK to a new civicrm_option_value (account_relationship)</comment>
+    <pseudoconstant>
+      <optionGroupName>account_relationship</optionGroupName>
+    </pseudoconstant>
   </field>  
   <field>
     <name>financial_account_id</name> 
     <required>true</required>
     <add>4.3</add>        
     <comment>FK to the financial_account_id</comment>
+    <pseudoconstant>
+      <table>civicrm_financial_account</table>
+      <keyColumn>id</keyColumn>
+      <labelColumn>name</labelColumn>
+    </pseudoconstant>
   </field>
   <foreignKey> 
     <name>financial_account_id</name> 
index 8c0fc0c68199fa5e2fda9017728195358c2f47bb..4895591596b57e562f5543fe9e464c79daecf68c 100644 (file)
@@ -54,6 +54,9 @@
     <default>3</default> 
     <add>4.3</add>
     <comment>pseudo FK into civicrm_option_value.</comment>
+    <pseudoconstant>
+      <optionGroupName>financial_account_type</optionGroupName>
+    </pseudoconstant>
   </field>
   <field>
     <name>accounting_code</name>
index 586b1c2eda73a64a1eefebfe5339fabf6ae26682..3e0c3ef1041f5618719661fc8ecf471e771c842f 100644 (file)
     <type>int unsigned</type>
     <comment>FK to civicrm_financial_account</comment>
     <add>4.3</add>
+    <pseudoconstant>
+      <table>civicrm_financial_account</table>
+      <keyColumn>id</keyColumn>
+      <labelColumn>name</labelColumn>
+    </pseudoconstant>
   </field>
   <foreignKey>
     <name>financial_account_id</name>
     <type>int unsigned</type>
     <comment>Payment status: test, paid, part_paid, unpaid (if empty assume unpaid)</comment>
     <add>4.3</add>
+    <pseudoconstant>
+      <optionGroupName>financial_item_status</optionGroupName>
+    </pseudoconstant>
   </field>
   <field>
     <name>entity_table</name>
index edea2e076ac490c034c266ea5bb7c0476b1dc966..36d21e0b82f7856be1f7ba196c61ecb8543ff150 100755 (executable)
     <type>int unsigned</type>   
     <comment>FK to financial_account table.</comment>   
     <add>4.3</add>
+    <pseudoconstant>
+      <table>civicrm_financial_account</table>
+      <keyColumn>id</keyColumn>
+      <labelColumn>name</labelColumn>
+    </pseudoconstant>
   </field> 
   <foreignKey> 
     <name>from_financial_account_id</name> 
     <type>int unsigned</type>  
     <comment>FK to financial_financial_account table.</comment>   
     <add>4.3</add>
+    <pseudoconstant>
+      <table>civicrm_financial_account</table>
+      <keyColumn>id</keyColumn>
+      <labelColumn>name</labelColumn>
+    </pseudoconstant>
   </field> 
   <foreignKey> 
     <name>to_financial_account_id</name>