-
-
Notifications
You must be signed in to change notification settings - Fork 814
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-21784 Display custom data when viewing recurring contributions #11697
CRM-21784 Display custom data when viewing recurring contributions #11697
Conversation
ec7defe
to
e5b17ac
Compare
@guanhuan looks like something you would have an interest in - would you like to assign a reviewer |
@eileenmcnaughton thanks for mentioning! I was on holiday last week but will assign someone to review this soon. |
@omarabuhussein please review this |
So after reading the technical details part ( I didn't checked the code yet) : 1- everything about the ticket indicate that it is about showing custom fields, but you only made another change which show the processor field in the rec contributions table , I don't think it is a good idea to do that and it is better to move that to a different PR even if it is just a small change. 2- I am not sure about switching to use APIs instead of BAO/DAO methods, I personally disagree with this concept, But I know this is something we discussed before with other people (including the core team) but still not sure if the core team reached to a conclusion about that. BTW, this sentence caught my attention :
I don't think for a function to be used once is a bad thing, reusing the code is not the only reason for creating new functions, another reason is to make the code more readable and clear. |
So I just took a quick look on the code and I think I need to wait a bit until I have an answers for my questions above. |
Regarding the deprecated function - I think that is a good move to deprecate that function & I think the usage of the api in this generally in line with what we have been doing in the code. I agree that the addition of the processor field could be contentious & should be a separate issue - in general there is a desire to make those fields profile-configurable across all the displays and I don't think it's just a minor change on this PR. @mattwire I think you should move that out of this PR. Note that other than code review this PR will require someone to confirm they have UI tested the change & the UI change is appropriate before it can be merged. I mention this because there are a few PRs which have stalled because people have done extension review of code style but not given the code a UI test or filled the review template & I've been left feeling unable to merge them despite a lot of work having gone into it. |
if this is the case then I will review based on that then.
I will do the UI testing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left few notes and questions, Beside that just one thing, Can you prepend the commit messages with the ticket number. that's beside moving "showing the payment processor" to another PR. I will do Manual testing after everything is fine,
CRM/Contribute/Page/Tab.php
Outdated
// no action allowed if it's not active | ||
$params[$ids]['is_active'] = ($recur['contribution_status_id'] != 3); | ||
$recurContributions[$recurId]['is_active'] = (!CRM_Contribute_BAO_Contribution::isContributionStatusNegative($recurDetail['contribution_status_id'])); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe this is more readable :
$statusID = $recurDetail['contribution_status_id'];
$recurContributions[$recurId]['is_active'] =
!(CRM_Contribute_BAO_Contribution::isContributionStatusNegative($statusID));
CRM/Contribute/Page/Tab.php
Outdated
@@ -131,44 +130,52 @@ public function browse() { | |||
$controller->run(); | |||
|
|||
// add recurring block | |||
$action = array_sum(array_keys($this->recurLinks())); | |||
$params = CRM_Contribute_BAO_ContributionRecur::getRecurContributions($this->_contactId); | |||
try { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know it was already like this, but better to improve it now, all the logic under "add recurring block" can be moved to a new private method with proper name (e.g addRecurringContributionsBlock).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@omarabuhussein Yes that's a good idea. It would be nice to refactor this in future to either create a separate tab, or introduce sortable columns etc. on the existing tab. Moving to the API means this is supported by the code, moving it to it's own function makes any future refactoring easier.
* | ||
* @return null|string | ||
*/ | ||
public static function getPaymentProcessorName($paymentProcessorId) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so if the BAO calls getting replaced by API calls elsewhere above, why to create new BAO method (even if it at the end use the API) instead of calling the API directly, because to be honest I am not clear on the line between when to use the API directly and when to use BAO methods in civicrm core code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@omarabuhussein @eileenmcnaughton Good question! I wanted to to something consistent (it's possible to have a recurring contribution with no payment processor ID, or an invalid one). I couldn't find a way of doing this via the UI without duplicating around 6 lines of code (which I abstracted into getPaymentProcessorName). Any thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess my position is that it's good to use the api because it's standardised & various hooks (include api-layer) work if you use the api but when there is a re-usable chunk then it makes sense to wrap that in a function. In this case the handling of the unknown situation is an extra bit of handling that the function provides. I would have thought that the FKs on the contribution_recur table would have meant we should not see an invalid processor id - but I'm not opposed to handling the posibility.
CiviCRM is never going to be a purist's codebase :-) which does mean we can't rely on rules as easily as we might in other codebases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay then :)
* @return null|string | ||
*/ | ||
public static function getPaymentProcessorName($paymentProcessorId) { | ||
// if there is a payment processor ID, get the name of the payment processor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really think this ID check is necessary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@omarabuhussein Ok, removed.
@@ -26,6 +26,10 @@ | |||
{include file="CRM/common/pager.tpl" location="top"} | |||
|
|||
{strip} | |||
<div class="description"> | |||
{ts}Click arrow to view payment details.{/ts} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not a native English speaker so I might be wrong, but isn't it more correct to be :
Click on the arrow to view the payment details.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@omarabuhussein @eileenmcnaughton I'm not sure that this text actually adds any value to the UI and might be better removed altogether?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ohh - I shy away totally at UI decisions. Gramatically I think no 'the' is probably better than with the 'the' - but I lean heavily on people like Andrew Hunt, Stoob, Pete D & Lcdweb for UI decisions - I didn't ping them because I thought pinging all 4 might be overkill :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant removing the entire description :-) Thoughts @agh1 @lcdservices ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
according to @lcdservices
And at this point, the arrows are ubiquitous throughout the system, so it may not need explanation.
I think I agree, so I think removing the entire description make sense here.
e5b17ac
to
e65014d
Compare
If we leave the text I would leave as is (no "the"). |
@mattwire so other than removing the message as well as removing the extra field from recurr contribution table and do it separate PR, I think all looks fine now, I will do some UI testing now and let you know here once done. |
So just finished testing, I can see that this change allow only for viewing the recurring contribution custom fields but it does not allow to edit them from UI, shouldn't editing be allowed too ? |
4221691
to
0993a4f
Compare
@omarabuhussein I've added custom data editing now and removed the "Click arrow to view payment details" text. Could you check the editing part and confirm if it is ok? |
sure @mattwire |
@mattwire editing works fine now , So it is approved from my side. But please update all commit messages to start with ticket number. @eileenmcnaughton unless you have anything to say, I think this fine to be merged after the commit messages get updated with the ticket number. |
0993a4f
to
0699333
Compare
@omarabuhussein @eileenmcnaughton Ok, updated commit messages and rebased. Good to merge? |
from my side yes @mattwire |
test this please |
1 similar comment
test this please |
I'm going to merge this based on @omarabuhussein review & it generally being a good idea to be able to see this custom data. I have some reservations about the implementation because I would like it to be generic enough to apply to 'any' entity - but I don't think it makes sense to block this until that is resolved |
Thanks for this! It is something I've been seeking, and now it's here without my even asking for it. Nice work! |
Overview
You can add custom data fields to recurring contributions easily via the custom data admin UI. However, it's not possible to view them anywhere except via the API. This PR fixes that so they show up when viewing the recurring contribution.
Before
Custom data not visible.
After
Custom data visible, using the same method as for other entities.
Note: processor column is no longer visible and has been moved to a separate issue: https://lab.civicrm.org/dev/financial/issues/4
Technical Details
This PR does 3 things:
Switch the data source for the recurring contributions on the contribution tab to use the API instead of BAO/DAO functions. This simplifies the code and makes all fields available to smarty so the tab can be easily customised by extensions (eg. to highlight ones with a particular custom field value). This also has the side-benefit of deprecating a BAO function that is only used once.
Switch the data source for the "View recurring contribution" page to use the API instead of BAO/DAO functions. This simplifies the code and makes all fields available so that the standard "view custom data" functions and smarty tpl can automatically display custom data in the standard format. This also makes "financial_type" visible at all times even if it cannot be changed - it makes sense to stop it being edited but I don't think it makes sense to hide it from view by default as well.
Modify the "View recurring contribution" page smarty template to add in the standard custom data template and allow custom data to magically appear.