Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CRM-19325 : Search contributions that are not in any batch #9492

Merged
merged 5 commits into from
Dec 9, 2016

Conversation

monishdeb
Copy link
Member

@monishdeb monishdeb commented Dec 2, 2016

@monishdeb
Copy link
Member Author

monishdeb commented Dec 2, 2016

This PR exhibit what form-value should be given to an attribute so that the value get eventually processed into fieldName IS (NOT) NULL or fieldName IS (NOT) EMPTY clause. These are the steps:

  1. Provide selectable or explicit value as in here IS NULL at https://github.com/civicrm/civicrm-core/pull/9492/files#diff-0a639f0cf282805e238274495195e6a4R1129

  2. Mention the fieldname in $specialParams array inside postprocess as in here . The value IS NULL got eventually formatted into OK (Operator as Key) format as array('IS NULL' => 1) as in here
    NOTE : if you only want to format the values for NULL/EMPTY value ONLY then mention the fieldName under $nullableFields as in here

  3. Basically we are formatting the value into OK format before the search query build like how the advance filters work in case of API and other search formvalues.

  4. Always call CRM_Contact_BAO_Query::buildQillForFieldValue(...) to build Qill operator and value respectively (as in here )

@monishdeb
Copy link
Member Author

@johanv its working for me, have a look!

Here's my test-cases :

  1. Exclude batch
    image

  2. Include batch
    image

  3. All contributions
    image

@eileenmcnaughton
Copy link
Contributor

There is a specific issue here (which it looks like you have solved) but, to test the solution further, how easy is it to expand it to search for contributions without pledges? If it is an elegant solution then hopefully we can start to add things like that on we get many requests of that variety (no membership, no event - or perhaps they could be replaced by 'no line item in this price set, with this price field, with this price label etc).

@monishdeb
Copy link
Member Author

monishdeb commented Dec 3, 2016

@eileenmcnaughton pretty simple. Here's my patch https://gist.github.com/monishdeb/c9a0c8da2d1ba29bc7e1cb99d0927a79 on top of this changes to support Is pledge Contribution? Yes/No

Is pledge Contribution?

-any-

image

Yes

image

No

image

@eileenmcnaughton
Copy link
Contributor

nice!

@eileenmcnaughton
Copy link
Contributor

any thoughts on unit tests?

@monishdeb
Copy link
Member Author

@eileenmcnaughton actually I didn't found any test coverage for Search Form other than Webtest. But lemme try to add one by using processSpecialFormValue(...) and CRM_Contact_BAO_Query instance to build search query.

@eileenmcnaughton
Copy link
Contributor

I think there are some group tests that use the search form.

I don't think webtests are really maintained /maintainable :-(

@monishdeb
Copy link
Member Author

Yup there are https://github.com/civicrm/civicrm-core/tree/master/tests/phpunit/CRM/Contact/Form/Search/Custom on custom search form and these operate on saved data set and use the custom queries to assert the result. Lemme check how I can make use of Advance Search post process.

@monishdeb monishdeb force-pushed the CRM-19325 branch 2 times, most recently from 8d33207 to f5d0c7a Compare December 7, 2016 08:50
@monishdeb
Copy link
Member Author

@monishdeb monishdeb force-pushed the CRM-19325 branch 2 times, most recently from f51d7dd to 9e3515a Compare December 8, 2016 05:26
@monishdeb
Copy link
Member Author

@eileenmcnaughton I am merging this PR as I have covered unit-test and highlighted the behaviour with screenshot

@monishdeb monishdeb merged commit efcfb86 into civicrm:master Dec 9, 2016
@monishdeb monishdeb deleted the CRM-19325 branch December 9, 2016 06:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants