From: Eileen McNaughton Date: Mon, 22 Jun 2015 23:49:57 +0000 (+1200) Subject: CRM-16627 add invoice id to contribution search X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=b5a37491ffc2bb06f689827f942a4e119c7dd60e;p=civicrm-core.git CRM-16627 add invoice id to contribution search --- diff --git a/CRM/Contribute/BAO/Query.php b/CRM/Contribute/BAO/Query.php index 9bee323ed9..c17a63211c 100644 --- a/CRM/Contribute/BAO/Query.php +++ b/CRM/Contribute/BAO/Query.php @@ -329,6 +329,7 @@ class CRM_Contribute_BAO_Query { case 'contribution_status': $name .= '_id'; case 'financial_type_id': + case 'invoice_id': case 'payment_instrument_id': case 'contribution_payment_instrument_id': case 'contribution_page_id': @@ -916,7 +917,7 @@ class CRM_Contribute_BAO_Query { // Add field for transaction ID search $form->addElement('text', 'contribution_trxn_id', ts("Transaction ID")); - + $form->addElement('text', 'invoice_id', ts("Invoice ID")); $form->addElement('text', 'contribution_check_number', ts('Check Number')); // Add field for pcp display in roll search diff --git a/CRM/Contribute/Form/Search.php b/CRM/Contribute/Form/Search.php index c087449267..81da92e3a4 100644 --- a/CRM/Contribute/Form/Search.php +++ b/CRM/Contribute/Form/Search.php @@ -275,6 +275,7 @@ class CRM_Contribute_Form_Search extends CRM_Core_Form_Search { 'contribution_status_id', 'contribution_source', 'contribution_trxn_id', + 'invoice_id', ); foreach ($specialParams as $element) { $value = CRM_Utils_Array::value($element, $this->_formValues); diff --git a/templates/CRM/Contribute/Form/Search/Common.tpl b/templates/CRM/Contribute/Form/Search/Common.tpl index 9e55106e75..a6b56a796c 100644 --- a/templates/CRM/Contribute/Form/Search/Common.tpl +++ b/templates/CRM/Contribute/Form/Search/Common.tpl @@ -57,13 +57,15 @@ {$form.contribution_or_softcredits.label}
{$form.contribution_or_softcredits.html} - -
{$form.contribution_soft_credit_type_id.label}
{$form.contribution_soft_credit_type_id.html|crmAddClass:twenty}
+ + {$form.invoice_id.label}
+ {$form.invoice_id.html} + diff --git a/tests/phpunit/api/v3/ContributionTest.php b/tests/phpunit/api/v3/ContributionTest.php index 3d75bae1f4..5c5fc60f39 100644 --- a/tests/phpunit/api/v3/ContributionTest.php +++ b/tests/phpunit/api/v3/ContributionTest.php @@ -504,6 +504,25 @@ class api_v3_ContributionTest extends CiviUnitTestCase { $this->assertEquals(1, $contribution['count']); } + /** + * CRM-16227 introduces invoice_id as a parameter. + */ + public function testGetContributionByInvoice() { + $this->callAPISuccess('Contribution', 'create', array_merge($this->_params, array('invoice_id' => 'curly'))); + $this->callAPISuccess('Contribution', 'create', array_merge($this->_params), array('invoice_id' => 'churlish')); + $this->callAPISuccessGetCount('Contribution', array(), 2); + $this->callAPISuccessGetSingle('Contribution', array('invoice_id' => 'curly')); + // The following don't work. They are the format we are trying to introduce but although the form uses this format + // CRM_Contact_BAO_Query::convertFormValues puts them into the other format & the where only supports that. + // ideally the where clause would support this format (as it does on contact_BAO_Query) and those lines would + // come out of convertFormValues + // $this->callAPISuccessGetSingle('Contribution', array('invoice_id' => array('LIKE' => '%ish%'))); + // $this->callAPISuccessGetSingle('Contribution', array('invoice_id' => array('NOT IN' => array('curly')))); + // $this->callAPISuccessGetCount('Contribution', array('invoice_id' => array('LIKE' => '%ly%')), 2); + // $this->callAPISuccessGetCount('Contribution', array('invoice_id' => array('IN' => array('curly', 'churlish'))), + // 2); + } + /** * Create test with unique field name on source. */