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-21354 : Allow "Advanced Search" to search for recurring contribution status. #11080

Merged
merged 1 commit into from
Oct 27, 2017
Merged

CRM-21354 : Allow "Advanced Search" to search for recurring contribution status. #11080

merged 1 commit into from
Oct 27, 2017

Conversation

waddyvic
Copy link

@waddyvic waddyvic commented Oct 7, 2017

Overview

Advanced search wasn't capable of searching for contacts with a specific recurring contribution status. I've added this field in Advanced Search to find people that are currently a monthly donors (status In Progress) or has been a monthly donors before (status "Cancelled" or "Completed").


@civicrm-builder
Copy link

Can one of the admins verify this patch?

@seamuslee001
Copy link
Contributor

Jenkins ok to test

@MegaphoneJon
Copy link
Contributor

Jenkins ok to retest

// Add field for contribution status
$contributionStatus = CRM_Contribute_PseudoConstant::contributionStatus();
$form->addSelect('contribution_recur_contribution_status_id',
array('entity' => 'contribution', 'multiple' => 'multiple', 'context' => 'search', 'options' => $contributionStatus)
Copy link
Member

@monishdeb monishdeb Oct 13, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you directly use the function in options i.e.
..., 'options' => CRM_Contribute_PseudoConstant::contributionStatus()
because $contributionStatus isn't used anywhere else.

case 'contribution_recur_contribution_status_id':
$query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("civicrm_contribution_recur.contribution_status_id", $op, $value, 'String');
list($op, $value) = CRM_Contact_BAO_Query::buildQillForFieldValue('CRM_Contribute_DAO_ContributionRecur', 'contribution_status_id', $value, $op, $pseudoExtraParam);
$query->_qill[$grouping][] = ts('%1 %2 %3', array(1 => 'Recurring Contribution Status', 2 => $op, 3 => $value));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add single quotation around status value to highlight the statuses, because it qill odd for In progress status :
screen shot 2017-10-13 at 11 33 44 am

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure thing.

I was wondering if I should quote the status values when I developed this field, but when I checked the output for normal contribution status (not recurring), there was no quote. So I just followed core behaviour.

contribution status output

@monishdeb
Copy link
Member

monishdeb commented Oct 13, 2017

Great work @waddyvic 👍 Apart from the two changes I have mentioned in the patch, I need point out some general issue with this PR:

  1. Is there a JIRA ticket raised for this change? If not please create one in https://issues.civicrm.org and mention the ticket no. in PR title as CRM-# : Allow "Advanced Search" to search for recurring contribution status.
  2. I can see a false commit 6f00ce3 it seems like you tried to pull the latest change in your branch. To avoid this try always to rebase against pull. Here are the steps:
$ git fetch upstream master // if upstream is pointing at [email protected]:civicrm/civicrm-core.git
$ git pull --rebase upstream master // if you got any merge conflict resolve them manually
$ git push -f origin advanced-search-recur-status //if origin is pointing at [email protected]: waddyvic/civicrm-core.git
  1. Can you add a UT (unit test) for this new field? Let me show an example how UTfor contribution filters were added, see - https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/CRM/Contribute/Form/SearchTest.php
    Ping me (alias - @Monish) on MM https://chat.civicrm.org/civicrm/channels/dev if you need help :)

@waddyvic
Copy link
Author

Hey @monishdeb thx for reviewing my PR. To respond to your previous comments:

  1. I just signed up an account on civicrm.org, pending approval. Will create an issue as soon as I can login.
  2. Thx for pointing out best practices of PR. I didn't do this enough to know exactly what steps to follow. I'll use rebase from now on before creating PR.
  3. I'll add a UT for this field as soon as possible.


// Add field for contribution status
$form->addSelect('contribution_recur_contribution_status_id',
array('entity' => 'contribution', 'multiple' => 'multiple', 'context' => 'search', 'options' => CRM_Contribute_PseudoConstant::contributionStatus() )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the related test build failure https://test.civicrm.org/job/CiviCRM-Core-PR/17604/checkstyleResult/new/

It says There should be no white space before a closing ")" so I would say that's a style error. As per coding standard there shouldn't be any trailing space before/after parenthesis.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOL my supervisor had his own coding guidelines which goes against the community. It's fixed now.


// Add field for contribution status
$form->addSelect('contribution_recur_contribution_status_id',
array('entity' => 'contribution', 'multiple' => 'multiple', 'context' => 'search', 'options' => CRM_Contribute_PseudoConstant::contributionStatus()),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops you left a comma ...CRM_Contribute_PseudoConstant::contributionStatus()), at then end. Causes test failure again :(

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds like I need to install PHP code sniffer after all

@waddyvic
Copy link
Author

Hi @monishdeb, I've added a unit test for the recurring contribution status search field. I'm still waiting for my account on issues.civicrm.org approved, so couldn't create an issue on there yet. I couldn't find how to contact the site's admin to approve my registration. Do you have any lead on this?

@monishdeb
Copy link
Member

Great work. @colemanw can you please approve the JIRA account of @waddyvic ?

@monishdeb
Copy link
Member

@waddyvic any luck? Or can you ask in mattermost dev-channel https://chat.civicrm.org/civicrm/channels/dev to approve your JIRA account

@waddyvic
Copy link
Author

@monishdeb Still waiting. I've joined mattermost to ask for help.

@waddyvic waddyvic changed the title Allow "Advanced Search" to search for recurring contribution status. CRM-21354: Allow "Advanced Search" to search for recurring contribution status. Oct 25, 2017
@waddyvic waddyvic changed the title CRM-21354: Allow "Advanced Search" to search for recurring contribution status. CRM-21354 : Allow "Advanced Search" to search for recurring contribution status. Oct 25, 2017
@waddyvic
Copy link
Author

@monishdeb OK got it sorted out. issue number is CRM-21354

case 'contribution_recur_contribution_status_id':
$query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("civicrm_contribution_recur.contribution_status_id", $op, $value, 'String');
list($op, $value) = CRM_Contact_BAO_Query::buildQillForFieldValue('CRM_Contribute_DAO_ContributionRecur', 'contribution_status_id', $value, $op, $pseudoExtraParam);
$query->_qill[$grouping][] = ts("%1 %2 '%3'", array(1 => 'Recurring Contribution Status', 2 => $op, 3 => $value));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you change it to

$query->_qill[$grouping][] = ts("Recurring Contribution Status %1 '%2'", array(1 => $op, 2 => $value));

@monishdeb
Copy link
Member

monishdeb commented Oct 25, 2017

Great.. one last change. Can you squash your 8 commits into 1? Here's the steps:

$ git fetch upstream master // if upstream is pointing to civicrm/civicrm-core.git
$ git pull --rebase upstream master
$ git rebase -i //this will open a vi edit screen
// now on vi edit screen, except 1st commit, change 'pick' to 'squash' against all subsequent commits, then save
$ git push -f origin advanced-search-recur-status

…ecurring contribution status(es).

CRM_Contribute_BAO_ContributionRecur: add multi-select dropdown field to select recurring contribution status.

CRM_Contribute_BAO_Query: add case to construct where clause for recurring contribution status.

templates/CRM/Contribute/Form/Search/ContributionRecur.tpl: add recurring contribution status field in template.

#11080

Add quotes around recurring contribution status qill.

#11080

Directly use CRM_Contribute_PseudoConstant::contributionStatus() instead
of creating variable that is not used anywhere else.

Remove space after closing ) to comply with coding standard

Remove comma after closing ) to comply with coding standard

Add unit test for recurring contribution status filter

Fix coding style error: The closing brace for the class must have an empty line before it

Do not use variable replacement in qill for static text "Recurring
Contribution Status".
@waddyvic
Copy link
Author

Hi @monishdeb , I did what you requested and it's pushed now.

@monishdeb
Copy link
Member

monishdeb commented Oct 27, 2017

Perfect 👍 Tested the latest patch and it worked for me. Happy with the final patch. Hence merging.

@monishdeb monishdeb merged commit 08c2d3c into civicrm:master Oct 27, 2017
@monishdeb
Copy link
Member

Congrats @waddyvic .. Keep up the good work :D

@waddyvic waddyvic deleted the advanced-search-recur-status branch October 27, 2017 19:16
@waddyvic
Copy link
Author

Thx for all your help on this @monishdeb

sluc23 pushed a commit to ixiam/civicrm-core that referenced this pull request Jan 10, 2018
…status

CRM-21354 : Allow "Advanced Search" to search for recurring contribution status.
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.

5 participants