Additional fixes in report and Search form
authordeb.monish <monish.deb@jmaconsulting.biz>
Tue, 18 Apr 2017 07:28:33 +0000 (12:58 +0530)
committerdeb.monish <monish.deb@jmaconsulting.biz>
Tue, 18 Apr 2017 08:03:17 +0000 (13:33 +0530)
17 files changed:
CRM/Contribute/BAO/Contribution.php
CRM/Contribute/BAO/Query.php
CRM/Core/BAO/FinancialTrxn.php
CRM/Report/Form/Contribute/Bookkeeping.php
CRM/Report/Form/Contribute/Detail.php
CRM/Report/Form/Contribute/History.php
CRM/Report/Form/Contribute/HouseholdSummary.php
CRM/Report/Form/Contribute/Lybunt.php
CRM/Report/Form/Contribute/OrganizationSummary.php
CRM/Report/Form/Contribute/PCP.php
CRM/Report/Form/Contribute/Recur.php
CRM/Report/Form/Contribute/SoftCredit.php
CRM/Report/Form/Contribute/Summary.php
CRM/Report/Form/Contribute/Sybunt.php
CRM/Report/Form/Contribute/TopDonor.php
templates/CRM/Contribute/Form/Search/Common.tpl
tests/phpunit/CRM/Core/BAO/FinancialTrxnTest.php

index a196c7c53bcbd09c53bf147e6a0d209e1e371b31..6e715176d1cb88db73ed3e56f1c30fa059d2e992 100644 (file)
@@ -3371,7 +3371,7 @@ INNER JOIN civicrm_activity ON civicrm_activity_contact.activity_id = civicrm_ac
               civicrm_api3('FinancialTrxn', 'create', array('id' => $refundIDs['financialTrxnId'], 'trxn_id' => $params['refund_trxn_id']));
             }
           }
-          $cardType = CRM_Utils_Array::value('card_type', $params);
+          $cardType = CRM_Utils_Array::value('card_type_id', $params);
           $panTruncation = CRM_Utils_Array::value('pan_truncation', $params);
           CRM_Core_BAO_FinancialTrxn::updateCreditCardDetails($params['contribution']->id, $panTruncation, $cardType);
         }
@@ -4066,7 +4066,7 @@ WHERE eft.financial_trxn_id IN ({$trxnId}, {$baseTrxnId['financialTrxnId']})
         SELECT GROUP_CONCAT(fa.`name`) as financial_account,
           ft.total_amount,
           ft.payment_instrument_id,
-          ft.trxn_date, ft.trxn_id, ft.status_id, ft.check_number, ft.currency, ft.pan_truncation, ft.card_type
+          ft.trxn_date, ft.trxn_id, ft.status_id, ft.check_number, ft.currency, ft.pan_truncation, ft.card_type_id
 
         FROM civicrm_contribution con
           LEFT JOIN civicrm_entity_financial_trxn eft ON (eft.entity_id = con.id AND eft.entity_table = 'civicrm_contribution')
@@ -4088,8 +4088,8 @@ WHERE eft.financial_trxn_id IN ({$trxnId}, {$baseTrxnId['financialTrxnId']})
       while ($resultDAO->fetch()) {
         $paidByLabel = CRM_Core_PseudoConstant::getLabel('CRM_Core_BAO_FinancialTrxn', 'payment_instrument_id', $resultDAO->payment_instrument_id);
         $paidByName = CRM_Core_PseudoConstant::getName('CRM_Core_BAO_FinancialTrxn', 'payment_instrument_id', $resultDAO->payment_instrument_id);
-        if ($resultDAO->card_type) {
-          $creditCardType = CRM_Core_PseudoConstant::getLabel('CRM_Core_BAO_FinancialTrxn', 'card_type', $resultDAO->card_type);
+        if ($resultDAO->card_type_id) {
+          $creditCardType = CRM_Core_PseudoConstant::getLabel('CRM_Core_BAO_FinancialTrxn', 'card_type_id', $resultDAO->card_type_id);
           $pantruncation = '';
           if ($resultDAO->pan_truncation) {
             $pantruncation = ": {$resultDAO->pan_truncation}";
index 416cf0a9c104586f2f1e136494385396b785af55..185f38cfe75324c93d46ff137b5de06fc2a0fc3c 100644 (file)
@@ -443,11 +443,11 @@ class CRM_Contribute_BAO_Query extends CRM_Core_BAO_Query {
         $query->_tables['civicrm_financial_trxn'] = $query->_whereTables['civicrm_financial_trxn'] = 1;
         return;
 
-      case 'financial_trxn_card_type':
-        $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause('civicrm_financial_trxn.card_type', $op, $value);
+      case 'financial_trxn_card_type_id':
+        $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause('civicrm_financial_trxn.card_type_id', $op, $value);
         $query->_tables['civicrm_financial_trxn'] = $query->_whereTables['civicrm_financial_trxn'] = 1;
         $query->_tables['civicrm_contribution'] = $query->_whereTables['civicrm_contribution'] = 1;
-        list($op, $value) = CRM_Contact_BAO_Query::buildQillForFieldValue('CRM_Financial_DAO_FinancialTrxn', 'card_type', $value, $op);
+        list($op, $value) = CRM_Contact_BAO_Query::buildQillForFieldValue('CRM_Financial_DAO_FinancialTrxn', 'card_type_id', $value, $op);
         $query->_qill[$grouping][] = ts('Card Type %1 %2', array(1 => $op, 2 => $value));
         return;
 
@@ -967,7 +967,7 @@ class CRM_Contribute_BAO_Query extends CRM_Core_BAO_Query {
       )
     );
 
-    $form->addField('financial_trxn_card_type', array('entity' => 'FinancialTrxn', 'name' => 'card_type', 'action' => 'get'));
+    $form->addField('financial_trxn_card_type_id', array('entity' => 'FinancialTrxn', 'name' => 'card_type_id', 'action' => 'get'));
 
     $form->add('text', 'financial_trxn_pan_truncation', ts('Card Number'), array(
       'size' => 5,
index 1d22a677321444f6eb0af31ee742a72a091c2d1f..f2f448c3ddd4648bcaa7ff140146ec71026662fd 100644 (file)
@@ -723,7 +723,7 @@ WHERE ft.to_financial_account_id != {$toFinancialAccount} AND ft.to_financial_ac
     $financialTrxnId = $financialTrxn['financial_trxn_id'];
     $trxnparams = array('id' => $financialTrxnId);
     if (isset($cardType)) {
-      $trxnparams['card_type'] = $cardType;
+      $trxnparams['card_type_id'] = $cardType;
     }
     if (isset($panTruncation)) {
       $trxnparams['pan_truncation'] = $panTruncation;
index 351dcb729838f142d063235618a407d4acb51171..0309e36e31f002fd3ca6460533f89c69a9948c6b 100644 (file)
@@ -348,7 +348,7 @@ class CRM_Report_Form_Contribute_Bookkeeping extends CRM_Report_Form {
             'default' => TRUE,
           ),
           'card_type_id' => array(
-            'title' => ts('Credit Card Type ID'),
+            'title' => ts('Credit Card Type'),
           ),
         ),
         'filters' => array(
@@ -377,9 +377,9 @@ class CRM_Report_Form_Contribute_Bookkeeping extends CRM_Report_Form {
             'default' => array(1),
           ),
           'card_type_id' => array(
-            'title' => ts('Credit Card Type ID'),
+            'title' => ts('Credit Card Type'),
             'operatorType' => CRM_Report_Form::OP_MULTISELECT,
-            'options' => CRM_Core_PseudoConstant::get('CRM_Financial_DAO_FinancialTrxn', 'card_type_id'),
+            'options' => CRM_Financial_DAO_FinancialTrxn::buildOptions('card_type_id'),
             'default' => NULL,
             'type' => CRM_Utils_Type::T_STRING,
           ),
@@ -648,7 +648,7 @@ class CRM_Report_Form_Contribute_Bookkeeping extends CRM_Report_Form {
     $contributionTypes = CRM_Contribute_PseudoConstant::financialType();
     $paymentInstruments = CRM_Contribute_PseudoConstant::paymentInstrument();
     $contributionStatus = CRM_Contribute_PseudoConstant::contributionStatus();
-    $creditCardTypes = CRM_Core_PseudoConstant::get('CRM_Financial_DAO_FinancialTrxn', 'card_type_id');
+    $creditCardTypes = CRM_Financial_DAO_FinancialTrxn::buildOptions('card_type_id');
     foreach ($rows as $rowNum => $row) {
       // convert display name to links
       if (array_key_exists('civicrm_contact_sort_name', $row) &&
index 600e0daf371c7f183d515c4d370beff8c3ffc090..81f72ac16e56067a39a3e67169239c778896bc76 100644 (file)
@@ -293,13 +293,13 @@ class CRM_Report_Form_Contribute_Detail extends CRM_Report_Form {
         'dao' => 'CRM_Financial_DAO_FinancialTrxn',
         'fields' => array(
           'card_type_id' => array(
-            'title' => ts('Credit Card Type ID'),
+            'title' => ts('Credit Card Type'),
             'dbAlias' => 'GROUP_CONCAT(financial_trxn_civireport.card_type_id SEPARATOR ",")',
           ),
         ),
         'filters' => array(
           'card_type_id' => array(
-            'title' => ts('Credit Card Type ID'),
+            'title' => ts('Credit Card Type'),
             'operatorType' => CRM_Report_Form::OP_MULTISELECT,
             'options' => CRM_Financial_DAO_FinancialTrxn::buildOptions('card_type_id'),
             'default' => NULL,
index 85563c3777727ad03265e6e916d3c8a7f0681e95..0cb76f1fad74cab4ae3c2659eb562d179ef306e4 100644 (file)
@@ -274,13 +274,13 @@ class CRM_Report_Form_Contribute_History extends CRM_Report_Form {
         'dao' => 'CRM_Financial_DAO_FinancialTrxn',
         'fields' => array(
           'card_type_id' => array(
-            'title' => ts('Credit Card Type ID'),
+            'title' => ts('Credit Card Type'),
             'dbAlias' => 'GROUP_CONCAT(financial_trxn_civireport.card_type_id SEPARATOR ",")',
           ),
         ),
         'filters' => array(
           'card_type_id' => array(
-            'title' => ts('Credit Card Type ID'),
+            'title' => ts('Credit Card Type'),
             'operatorType' => CRM_Report_Form::OP_MULTISELECT,
             'options' => CRM_Financial_DAO_FinancialTrxn::buildOptions('card_type_id'),
             'default' => NULL,
index ac8da1e4afb055c90c472fdee9d9602b03c6caba..43135d64e31f964ec4a566265a2c2fa1466908e6 100644 (file)
@@ -165,13 +165,13 @@ class CRM_Report_Form_Contribute_HouseholdSummary extends CRM_Report_Form {
         'dao' => 'CRM_Financial_DAO_FinancialTrxn',
         'fields' => array(
           'card_type_id' => array(
-            'title' => ts('Credit Card Type ID'),
+            'title' => ts('Credit Card Type'),
             'dbAlias' => 'GROUP_CONCAT(financial_trxn_civireport.card_type_id SEPARATOR ",")',
           ),
         ),
         'filters' => array(
           'card_type_id' => array(
-            'title' => ts('Credit Card Type ID'),
+            'title' => ts('Credit Card Type'),
             'operatorType' => CRM_Report_Form::OP_MULTISELECT,
             'options' => CRM_Financial_DAO_FinancialTrxn::buildOptions('card_type_id'),
             'default' => NULL,
index 8ac77ee3db1a066fdaaab7bd5d88d67ed175857a..b0877276d6d6335f2f1cff9cffa732da7c3d2668 100644 (file)
@@ -253,13 +253,13 @@ class CRM_Report_Form_Contribute_Lybunt extends CRM_Report_Form {
         'dao' => 'CRM_Financial_DAO_FinancialTrxn',
         'fields' => array(
           'card_type_id' => array(
-            'title' => ts('Credit Card Type ID'),
+            'title' => ts('Credit Card Type'),
             'dbAlias' => 'GROUP_CONCAT(financial_trxn_civireport.card_type_id SEPARATOR ",")',
           ),
         ),
         'filters' => array(
           'card_type_id' => array(
-            'title' => ts('Credit Card Type ID'),
+            'title' => ts('Credit Card Type'),
             'operatorType' => CRM_Report_Form::OP_MULTISELECT,
             'options' => CRM_Financial_DAO_FinancialTrxn::buildOptions('card_type_id'),
             'default' => NULL,
index bec6fff7cf37c30cad3e9e962374d8ce5813f9db..9a310fe91d8747d922bb28b6bb70a46faffba373 100644 (file)
@@ -197,13 +197,13 @@ class CRM_Report_Form_Contribute_OrganizationSummary extends CRM_Report_Form {
         'dao' => 'CRM_Financial_DAO_FinancialTrxn',
         'fields' => array(
           'card_type_id' => array(
-            'title' => ts('Credit Card Type ID'),
+            'title' => ts('Credit Card Type'),
             'dbAlias' => 'GROUP_CONCAT(financial_trxn_civireport.card_type_id SEPARATOR ",")',
           ),
         ),
         'filters' => array(
           'card_type_id' => array(
-            'title' => ts('Credit Card Type ID'),
+            'title' => ts('Credit Card Type'),
             'operatorType' => CRM_Report_Form::OP_MULTISELECT,
             'options' => CRM_Financial_DAO_FinancialTrxn::buildOptions('card_type_id'),
             'default' => NULL,
index 22d57dbf56434f2638d364217c443d2d1b052085..bc3506824efabb78740439e4dcaa271b074a96a8 100644 (file)
@@ -170,13 +170,13 @@ class CRM_Report_Form_Contribute_PCP extends CRM_Report_Form {
         'dao' => 'CRM_Financial_DAO_FinancialTrxn',
         'fields' => array(
           'card_type_id' => array(
-            'title' => ts('Credit Card Type ID'),
+            'title' => ts('Credit Card Type'),
             'dbAlias' => 'GROUP_CONCAT(financial_trxn_civireport.card_type_id SEPARATOR ",")',
           ),
         ),
         'filters' => array(
           'card_type_id' => array(
-            'title' => ts('Credit Card Type ID'),
+            'title' => ts('Credit Card Type'),
             'operatorType' => CRM_Report_Form::OP_MULTISELECT,
             'options' => CRM_Financial_DAO_FinancialTrxn::buildOptions('card_type_id'),
             'default' => NULL,
index d3510c2002e92d48927e839de283c248c09ad78e..602b8f5607fbd95774ad6407bae13c28475d85db 100644 (file)
@@ -110,13 +110,13 @@ class CRM_Report_Form_Contribute_Recur extends CRM_Report_Form {
         'dao' => 'CRM_Financial_DAO_FinancialTrxn',
         'fields' => array(
           'card_type_id' => array(
-            'title' => ts('Credit Card Type ID'),
+            'title' => ts('Credit Card Type'),
             'dbAlias' => 'GROUP_CONCAT(financial_trxn_civireport.card_type_id SEPARATOR ",")',
           ),
         ),
         'filters' => array(
           'card_type_id' => array(
-            'title' => ts('Credit Card Type ID'),
+            'title' => ts('Credit Card Type'),
             'operatorType' => CRM_Report_Form::OP_MULTISELECT,
             'options' => CRM_Financial_DAO_FinancialTrxn::buildOptions('card_type_id'),
             'default' => NULL,
index 45806b552422591639ad6f9e965e98f0ff853dff..0ad8445917a259b978c92c0a0e42d833530de127 100644 (file)
@@ -306,13 +306,13 @@ class CRM_Report_Form_Contribute_SoftCredit extends CRM_Report_Form {
         'dao' => 'CRM_Financial_DAO_FinancialTrxn',
         'fields' => array(
           'card_type_id' => array(
-            'title' => ts('Credit Card Type ID'),
+            'title' => ts('Credit Card Type'),
             'dbAlias' => 'GROUP_CONCAT(financial_trxn_civireport.card_type_id SEPARATOR ",")',
           ),
         ),
         'filters' => array(
           'card_type_id' => array(
-            'title' => ts('Credit Card Type ID'),
+            'title' => ts('Credit Card Type'),
             'operatorType' => CRM_Report_Form::OP_MULTISELECT,
             'options' => CRM_Financial_DAO_FinancialTrxn::buildOptions('card_type_id'),
             'default' => NULL,
index 16984a8f3ca253d804727b456fcfe54f4a682c2f..5fd12b81bac2a6a606ca72b78431801e80a09a66 100644 (file)
@@ -230,7 +230,7 @@ class CRM_Report_Form_Contribute_Summary extends CRM_Report_Form {
         'dao' => 'CRM_Financial_DAO_FinancialTrxn',
         'fields' => array(
           'card_type_id' => array(
-            'title' => ts('Credit Card Type ID'),
+            'title' => ts('Credit Card Type'),
             'dbAlias' => 'GROUP_CONCAT(financial_trxn_civireport.card_type_id SEPARATOR ",")',
           ),
         ),
@@ -238,7 +238,7 @@ class CRM_Report_Form_Contribute_Summary extends CRM_Report_Form {
           'card_type_id' => array(
             'title' => ts('Credit Card Type'),
             'operatorType' => CRM_Report_Form::OP_MULTISELECT,
-            'options' => CRM_Core_PseudoConstant::get('CRM_Financial_DAO_FinancialTrxn', 'card_type_id'),
+            'options' => CRM_Financial_DAO_FinancialTrxn::buildOptions('card_type_id'),
             'default' => NULL,
             'type' => CRM_Utils_Type::T_STRING,
           ),
index 2b428bdbe3754807074308baee616c822a640faf..2299e9d7b8df2159e250da8a8994b98afa5f7397 100644 (file)
@@ -251,13 +251,13 @@ class CRM_Report_Form_Contribute_Sybunt extends CRM_Report_Form {
         'dao' => 'CRM_Financial_DAO_FinancialTrxn',
         'fields' => array(
           'card_type_id' => array(
-            'title' => ts('Credit Card Type ID'),
+            'title' => ts('Credit Card Type'),
             'dbAlias' => 'GROUP_CONCAT(financial_trxn_civireport.card_type_id SEPARATOR ",")',
           ),
         ),
         'filters' => array(
           'card_type_id' => array(
-            'title' => ts('Credit Card Type ID'),
+            'title' => ts('Credit Card Type'),
             'operatorType' => CRM_Report_Form::OP_MULTISELECT,
             'default' => NULL,
             'options' => CRM_Financial_DAO_FinancialTrxn::buildOptions('card_type_id'),
index 766a8927555ce9f8950af60552f0100665b679bc..8a7ad5bead8502014d1d589ca6ce3f06a85cafe9 100644 (file)
@@ -166,13 +166,13 @@ class CRM_Report_Form_Contribute_TopDonor extends CRM_Report_Form {
         'dao' => 'CRM_Financial_DAO_FinancialTrxn',
         'fields' => array(
           'card_type_id' => array(
-            'title' => ts('Credit Card Type ID'),
+            'title' => ts('Credit Card Type'),
             'dbAlias' => 'GROUP_CONCAT(financial_trxn_civireport.card_type_id SEPARATOR ",")',
           ),
         ),
         'filters' => array(
           'card_type_id' => array(
-            'title' => ts('Credit Card Type ID'),
+            'title' => ts('Credit Card Type'),
             'operatorType' => CRM_Report_Form::OP_MULTISELECT,
             'options' => CRM_Financial_DAO_FinancialTrxn::buildOptions('card_type_id'),
             'default' => NULL,
index f1bd95f629d20a82254c8a77581fb3a06705ced3..2e601e47a0b4bc9028bdc4ecf2416e75442c4989 100644 (file)
@@ -47,9 +47,9 @@
       {$form.contribution_check_number.label} <br />
       {$form.contribution_check_number.html}
     </div>
-    <div class="float-left" id="financial_trxn_card_type_wrapper">
-      {$form.financial_trxn_card_type.label} <br />
-      {$form.financial_trxn_card_type.html}
+    <div class="float-left" id="financial_trxn_card_type_id_wrapper">
+      {$form.financial_trxn_card_type_id.label} <br />
+      {$form.financial_trxn_card_type_id.html}
     </div>
     <div class="float-left" id="pan_truncation_wrapper">
       {$form.financial_trxn_pan_truncation.label} <br />
index 5fdf40cebc9eec5047369d57779fd73fdcca9ded..aa354f26f794f300bb0f61a3f7b3db8cb9fa1dd9 100644 (file)
@@ -188,13 +188,13 @@ class CRM_Core_BAO_FinancialTrxnTest extends CiviUnitTestCase {
       'FinancialTrxn',
       array(
         'id' => $lastFinancialTrxnId['financialTrxnId'],
-        'return' => array('card_type', 'pan_truncation'),
+        'return' => array('card_type_id', 'pan_truncation'),
       )
     );
-    $this->assertEquals(CRM_Utils_Array::value('card_type', $financialTrxn), NULL);
+    $this->assertEquals(CRM_Utils_Array::value('card_type_id', $financialTrxn), NULL);
     $this->assertEquals(CRM_Utils_Array::value('pan_truncation', $financialTrxn), NULL);
     $params = array(
-      'card_type' => 2,
+      'card_type_id' => 2,
       'pan_truncation' => 4567,
       'id' => $contribution->id,
     );
@@ -203,10 +203,10 @@ class CRM_Core_BAO_FinancialTrxnTest extends CiviUnitTestCase {
       'FinancialTrxn',
       array(
         'id' => $lastFinancialTrxnId['financialTrxnId'],
-        'return' => array('card_type', 'pan_truncation'),
+        'return' => array('card_type_id', 'pan_truncation'),
       )
     );
-    $this->assertEquals($financialTrxn['card_type'], 2);
+    $this->assertEquals($financialTrxn['card_type_id'], 2);
     $this->assertEquals($financialTrxn['pan_truncation'], 4567);
   }
 
@@ -227,20 +227,20 @@ class CRM_Core_BAO_FinancialTrxnTest extends CiviUnitTestCase {
       'FinancialTrxn',
       array(
         'id' => $lastFinancialTrxnId['financialTrxnId'],
-        'return' => array('card_type', 'pan_truncation'),
+        'return' => array('card_type_id', 'pan_truncation'),
       )
     );
-    $this->assertEquals(CRM_Utils_Array::value('card_type', $financialTrxn), NULL);
+    $this->assertEquals(CRM_Utils_Array::value('card_type_id', $financialTrxn), NULL);
     $this->assertEquals(CRM_Utils_Array::value('pan_truncation', $financialTrxn), NULL);
     CRM_Core_BAO_FinancialTrxn::updateCreditCardDetails($contribution->id, 4567, 2);
     $financialTrxn = $this->callAPISuccessGetSingle(
       'FinancialTrxn',
       array(
         'id' => $lastFinancialTrxnId['financialTrxnId'],
-        'return' => array('card_type', 'pan_truncation'),
+        'return' => array('card_type_id', 'pan_truncation'),
       )
     );
-    $this->assertEquals($financialTrxn['card_type'], 2);
+    $this->assertEquals($financialTrxn['card_type_id'], 2);
     $this->assertEquals($financialTrxn['pan_truncation'], 4567);
   }