From d72b084aac44d729ff3e47e3d9d8783b6be0f492 Mon Sep 17 00:00:00 2001 From: "deb.monish" Date: Tue, 18 Apr 2017 12:58:33 +0530 Subject: [PATCH] Additional fixes in report and Search form --- CRM/Contribute/BAO/Contribution.php | 8 ++++---- CRM/Contribute/BAO/Query.php | 8 ++++---- CRM/Core/BAO/FinancialTrxn.php | 2 +- CRM/Report/Form/Contribute/Bookkeeping.php | 8 ++++---- CRM/Report/Form/Contribute/Detail.php | 4 ++-- CRM/Report/Form/Contribute/History.php | 4 ++-- .../Form/Contribute/HouseholdSummary.php | 4 ++-- CRM/Report/Form/Contribute/Lybunt.php | 4 ++-- .../Form/Contribute/OrganizationSummary.php | 4 ++-- CRM/Report/Form/Contribute/PCP.php | 4 ++-- CRM/Report/Form/Contribute/Recur.php | 4 ++-- CRM/Report/Form/Contribute/SoftCredit.php | 4 ++-- CRM/Report/Form/Contribute/Summary.php | 4 ++-- CRM/Report/Form/Contribute/Sybunt.php | 4 ++-- CRM/Report/Form/Contribute/TopDonor.php | 4 ++-- .../CRM/Contribute/Form/Search/Common.tpl | 6 +++--- .../phpunit/CRM/Core/BAO/FinancialTrxnTest.php | 18 +++++++++--------- 17 files changed, 47 insertions(+), 47 deletions(-) diff --git a/CRM/Contribute/BAO/Contribution.php b/CRM/Contribute/BAO/Contribution.php index a196c7c53b..6e715176d1 100644 --- a/CRM/Contribute/BAO/Contribution.php +++ b/CRM/Contribute/BAO/Contribution.php @@ -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}"; diff --git a/CRM/Contribute/BAO/Query.php b/CRM/Contribute/BAO/Query.php index 416cf0a9c1..185f38cfe7 100644 --- a/CRM/Contribute/BAO/Query.php +++ b/CRM/Contribute/BAO/Query.php @@ -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, diff --git a/CRM/Core/BAO/FinancialTrxn.php b/CRM/Core/BAO/FinancialTrxn.php index 1d22a67732..f2f448c3dd 100644 --- a/CRM/Core/BAO/FinancialTrxn.php +++ b/CRM/Core/BAO/FinancialTrxn.php @@ -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; diff --git a/CRM/Report/Form/Contribute/Bookkeeping.php b/CRM/Report/Form/Contribute/Bookkeeping.php index 351dcb7298..0309e36e31 100644 --- a/CRM/Report/Form/Contribute/Bookkeeping.php +++ b/CRM/Report/Form/Contribute/Bookkeeping.php @@ -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) && diff --git a/CRM/Report/Form/Contribute/Detail.php b/CRM/Report/Form/Contribute/Detail.php index 600e0daf37..81f72ac16e 100644 --- a/CRM/Report/Form/Contribute/Detail.php +++ b/CRM/Report/Form/Contribute/Detail.php @@ -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, diff --git a/CRM/Report/Form/Contribute/History.php b/CRM/Report/Form/Contribute/History.php index 85563c3777..0cb76f1fad 100644 --- a/CRM/Report/Form/Contribute/History.php +++ b/CRM/Report/Form/Contribute/History.php @@ -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, diff --git a/CRM/Report/Form/Contribute/HouseholdSummary.php b/CRM/Report/Form/Contribute/HouseholdSummary.php index ac8da1e4af..43135d64e3 100644 --- a/CRM/Report/Form/Contribute/HouseholdSummary.php +++ b/CRM/Report/Form/Contribute/HouseholdSummary.php @@ -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, diff --git a/CRM/Report/Form/Contribute/Lybunt.php b/CRM/Report/Form/Contribute/Lybunt.php index 8ac77ee3db..b0877276d6 100644 --- a/CRM/Report/Form/Contribute/Lybunt.php +++ b/CRM/Report/Form/Contribute/Lybunt.php @@ -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, diff --git a/CRM/Report/Form/Contribute/OrganizationSummary.php b/CRM/Report/Form/Contribute/OrganizationSummary.php index bec6fff7cf..9a310fe91d 100644 --- a/CRM/Report/Form/Contribute/OrganizationSummary.php +++ b/CRM/Report/Form/Contribute/OrganizationSummary.php @@ -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, diff --git a/CRM/Report/Form/Contribute/PCP.php b/CRM/Report/Form/Contribute/PCP.php index 22d57dbf56..bc3506824e 100644 --- a/CRM/Report/Form/Contribute/PCP.php +++ b/CRM/Report/Form/Contribute/PCP.php @@ -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, diff --git a/CRM/Report/Form/Contribute/Recur.php b/CRM/Report/Form/Contribute/Recur.php index d3510c2002..602b8f5607 100644 --- a/CRM/Report/Form/Contribute/Recur.php +++ b/CRM/Report/Form/Contribute/Recur.php @@ -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, diff --git a/CRM/Report/Form/Contribute/SoftCredit.php b/CRM/Report/Form/Contribute/SoftCredit.php index 45806b5524..0ad8445917 100644 --- a/CRM/Report/Form/Contribute/SoftCredit.php +++ b/CRM/Report/Form/Contribute/SoftCredit.php @@ -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, diff --git a/CRM/Report/Form/Contribute/Summary.php b/CRM/Report/Form/Contribute/Summary.php index 16984a8f3c..5fd12b81ba 100644 --- a/CRM/Report/Form/Contribute/Summary.php +++ b/CRM/Report/Form/Contribute/Summary.php @@ -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, ), diff --git a/CRM/Report/Form/Contribute/Sybunt.php b/CRM/Report/Form/Contribute/Sybunt.php index 2b428bdbe3..2299e9d7b8 100644 --- a/CRM/Report/Form/Contribute/Sybunt.php +++ b/CRM/Report/Form/Contribute/Sybunt.php @@ -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'), diff --git a/CRM/Report/Form/Contribute/TopDonor.php b/CRM/Report/Form/Contribute/TopDonor.php index 766a892755..8a7ad5bead 100644 --- a/CRM/Report/Form/Contribute/TopDonor.php +++ b/CRM/Report/Form/Contribute/TopDonor.php @@ -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, diff --git a/templates/CRM/Contribute/Form/Search/Common.tpl b/templates/CRM/Contribute/Form/Search/Common.tpl index f1bd95f629..2e601e47a0 100644 --- a/templates/CRM/Contribute/Form/Search/Common.tpl +++ b/templates/CRM/Contribute/Form/Search/Common.tpl @@ -47,9 +47,9 @@ {$form.contribution_check_number.label}
{$form.contribution_check_number.html} -
- {$form.financial_trxn_card_type.label}
- {$form.financial_trxn_card_type.html} +
+ {$form.financial_trxn_card_type_id.label}
+ {$form.financial_trxn_card_type_id.html}
{$form.financial_trxn_pan_truncation.label}
diff --git a/tests/phpunit/CRM/Core/BAO/FinancialTrxnTest.php b/tests/phpunit/CRM/Core/BAO/FinancialTrxnTest.php index 5fdf40cebc..aa354f26f7 100644 --- a/tests/phpunit/CRM/Core/BAO/FinancialTrxnTest.php +++ b/tests/phpunit/CRM/Core/BAO/FinancialTrxnTest.php @@ -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); } -- 2.25.1