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-21343: Add cancel filters for Contribution search #11189

Closed
wants to merge 558 commits into from

Conversation

sluc23
Copy link
Contributor

@sluc23 sluc23 commented Oct 24, 2017

Overview

Add cancel reason and cancel date filters in Contribution search form
https://issues.civicrm.org/jira/browse/CRM-21343

Before

No cancel reason or cancel date fields in the form to be used as contribution filters

After

screenshot

@civicrm-builder
Copy link

Can one of the admins verify this patch?

@seamuslee001
Copy link
Contributor

Jenkins ok to test

@monishdeb
Copy link
Member

monishdeb commented Oct 25, 2017

@sluc23 nice work. I have reviewed your patch and here's few point I like to add on top of your changes:

  1. Can you shift the two fields to right, to utilize the space better?
  2. Can you add UT (unit test) for these two new filters? See how UT for 'card_type' is added here

@monishdeb monishdeb changed the title CRM-21343 - Add cancel filters for Contribution search CRM-21343: Add cancel filters for Contribution search Oct 25, 2017
@sluc23
Copy link
Contributor Author

sluc23 commented Oct 25, 2017

@monishdeb regarding UT, the issue is that the demo database doesn't have any Canceled Contribution.
What do you think it's the best way to deal with this if I need to create the UT based on the civibuild database?

@monishdeb
Copy link
Member

monishdeb commented Oct 25, 2017

@sluc23 true. You might have noticed that in order to write UT for card-type filter, first a dummy contribution is created using card type - see https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/CRM/Contribute/Form/SearchTest.php#L218

So, in this case, you need to create a dummy canceled contribution(s) using Contribution.create API. Hint:

public function testCancelReasonFilter() {
  $contactID = $this->individualCreate();
  $this->contributionCreate(array(   // this is a helper fn provided by Civi UT to create dummy contribution or if you don't like it use civicrm_api3('contribution', 'create', $params) instead
   'contact_id' => $contactID,
    'contribution_status_id' => 'Cancelled',
    'cancel_reason' => 'oops transaction failed',
   'cancel_date' => date('YmdHis'),
  ));
  ...
 }

Hope this helps :)

@sluc23
Copy link
Contributor Author

sluc23 commented Oct 25, 2017

@monishdeb regarding your 1. before doing the commits, you think this looks better?
1

At the right of Currency field there is a conditional Batch field which is not always shown (like in my screenshot), so it is not easy to move both fields at the right column, at the same level of Currency

@monishdeb
Copy link
Member

monishdeb commented Oct 25, 2017

@sluc23 sorry for late reply. Can you bring 'Personal Campaign Page' in right and below of 'Personal Campaign Page Honor Roll?' field. In that the 2 PCP fields will be rendered jointly and this will adjust the space well. What you say?

@sluc23
Copy link
Contributor Author

sluc23 commented Oct 26, 2017

@monishdeb like this?
1

Anyway the layout of this form is not very user friendly, many controls/labels are not aligned, not very intuitive to find fields.. I think some cosmetic adjustments would be nice to have to make this form look better, what do you think?

@monishdeb
Copy link
Member

monishdeb commented Oct 26, 2017

I think some cosmetic adjustments would be nice to have to make this form look better, what do you think?

I agree, but I'ld prefer to create a separate issue for that because I think the required change in tpl will be big and doesn't fit in the purpose of this issue.

Back to the screenshot, I like the view now, but will it be a simple fix to remove space above currency field?

@yashodha
Copy link
Contributor

@monishdeb @sluc23 while we are at moving around stuf, we should move the currency all the way up next to Contribution Amounts since it belongs there IMO. What do you guys think?

@sluc23
Copy link
Contributor Author

sluc23 commented Nov 3, 2017

@yashodha @monishdeb something like this?
remember that at the right of currency fields there is a hidden Contribution Batch field, which is shown conditionally

1

@monishdeb
Copy link
Member

Yeah, it looks good now. :)

case 'contribution_cancel_date_high_time':
// process to / from date
$query->dateQueryBuilder($values,
'civicrm_contribution', 'contribution_cancel_date', 'cancel_date', 'Contribution Cancel Date'
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 wrap "Contribution Cancel Date" in ts() ? -- and also the 2-3 other occurrences of dateQueryBuilder() which should have been wrapped as well.

Copy link
Member

Choose a reason for hiding this comment

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

.. and possibly use the same label as "Cancelled / Refunded Date"? (This is shown in the search results, I think?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mlutfy sure.. what do you think about here (line 1066):

    // we only have recurring dates using this ATM so lets' short cut to find the table name
    $table = 'contribution_recur';
    $fieldName = explode($table . '_', $field);
    $query->dateQueryBuilder($values,
      'civicrm_' . $table, $field, $fieldName[1], $title
    );
    return TRUE;
  }

should I wrap it as

$query->dateQueryBuilder($values,
      'civicrm_' . $table, $field, $fieldName[1], ts($title)
    );

?

Copy link
Member

@mlutfy mlutfy Nov 15, 2017

Choose a reason for hiding this comment

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

@sluc23 No, because gettext/civistrings uses the ts() function to detect which strings to extract (to send to Transifex). So while ts($title) would send the text through gettext, the actual string would not be present in the translation dictionary.
In other words, ts() means:

  • "lookup this string in the translation dictionary (civicrm.mo)"
  • "and send this string to Transifex".
    Hence a string must not include a variable, since we do not know what the value of the variable is during extraction time (which is done as a c-i process outside program execution).

@eileenmcnaughton
Copy link
Contributor

@monishdeb looks like you have mostly reviewed this?

@monishdeb
Copy link
Member

monishdeb commented Jan 9, 2018

@eileenmcnaughton yes and I am happy with the patch. @sluc23 did really good job in addressing all the additional issues raised during QA. Only thing remaining to get this PR merged is adding new/extended-existing UT on those two new search filters. @sluc23 are you going to add UT? Please ping me on mattermost (alias @Monish) if you need my help :)

eileenmcnaughton and others added 13 commits January 10, 2018 11:54
CRM-21478 Using contribution status id instead of label in if statement
Changed direct access to $currentOption array by using the
CRM_Utils_Array::value() wrapper, so no notices are issued.
…-empty-visibility

CRM-21328: Remove '-select-' Option From Visibility
CRM-21342 - Contribution note is not wiped if the value is removed
CRM-21471 remove unused core function CRM_Core_Pseudoconstant::greeti…
CRM-21433: Optimize dupe checking in Recent Items stack
…n_recurring_detail

CRM-21504 Add membership to recurring contribution detail
eileenmcnaughton and others added 19 commits January 10, 2018 11:57
----------------------------------------
* CRM-21050: credit card invoice: receive time set to 12:00
  https://issues.civicrm.org/jira/browse/CRM-21050
CRM-21050: Use datepicker for all date fields used in contribution backoffice form
CRM-21554 Offline Credit Card Membership Renewal not showing any error message on failure
…tus-of-linked-cases

CRM-21498: Implement Option to Change Status of Linked Cases
…ages was not set (adds unit-test fix by Monish Deb)
CRM-21609 - Correctly handle PayPalPro recurring payments whose amoun…
----------------------------------------
* CRM-21644: Preferred Communication Method is not set to default for contact
  https://issues.civicrm.org/jira/browse/CRM-21644
CRM-21627: makeMultilingual: update dbLocale to avoid fatal if lcMessages was not set
CRM-21644, Fixed set default for Preferred Communication Method
@sluc23
Copy link
Contributor Author

sluc23 commented Jan 10, 2018

@monishdeb I've added unit test, and rebased into master.
I'm getting a conflict in the file I've edited to add the test.. I'm not sure why it's showing me that error..

any clue?

@monishdeb
Copy link
Member

@sluc23 you might have git pull in an attempt to doing rebase, reason why you lots of false commits in your PR. Can you create a new PR and close this one?

@eileenmcnaughton
Copy link
Contributor

In general to rebase I do

git pull --rebase origin master

& then I do a second one

git pull -i origin/master

(the second one allows for squashing of commits & tweaking commit messages)

You need to use the -f switch when you push

git push -f myrepo CRM-21343
(where CRM-21343 is your branch name - myrepo will need changing to your repo name)

@sluc23
Copy link
Contributor Author

sluc23 commented Feb 6, 2018

New PR created --> #11638

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.