-
-
Notifications
You must be signed in to change notification settings - Fork 824
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-20610 expose payment edit form on the contribution page #10776
Conversation
CRM/Contribute/Form/Contribution.php
Outdated
foreach (array( | ||
'payment_instrument_id', | ||
'check_number', | ||
// ****** @Monish - is this suppose to be trxn_date!? |
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.
???
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 wait this was included because I didn't included the fix #10680 about removing check_number from payment details block
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 we can simply remove check_number. trxn_date is handled below. See at submit() function
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.
& remove receive_date & my comment too :-)
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.
Actually - foreach might be working against legibility now
</table> | ||
{/if} | ||
</div> | ||
</div> | ||
{/if} | ||
|
||
{include file='CRM/Core/BillingBlockWrapper.tpl'} |
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 left off the change to this as I want to understand it better - my understanding is that it pre-exists & is not made worse by this?
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.
Nope, it's needed for live mode. And won't affect the offline mode in addition to the new changes
@@ -241,52 +241,58 @@ | |||
</table> | |||
|
|||
{if !$contributionMode} | |||
<fieldset class="payment-details_group"> |
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.
This is obviously the main part. I have mixed feelings about the re-emergence of the accordian - but I don't presume to be the best opinion on that & aesthetic changes can happen later
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.
oh bugger I was wrong - this is all about contribution Mode - yuck. will rethink
<legend> | ||
{ts}Payment Details{/ts} | ||
</legend> | ||
<table class="form-layout-compressed" > |
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.
Anything in this table will not show on the NEW contribution form (I actually think it's kinda tidy the way it works)
</legend> | ||
<table class="form-layout-compressed" > | ||
<tr class="crm-contribution-form-block-payment_instrument_id"> | ||
<td class="label">{$form.payment_instrument_id.label}</td> |
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.
ok - transaction field
</td> | ||
</tr> | ||
{if $showCheckNumber || !$isOnline} | ||
<tr id="checkNumber" class="crm-contribution-form-block-check_number"> |
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.
ok - transaction field
</tr> | ||
{/if} | ||
<tr class="crm-contribution-form-block-trxn_id"> | ||
<td class="label">{$form.trxn_id.label}</td> |
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.
ok - transaction field, but I do wonder with this & check_number if we should 'bubble up' payment edits to the contribution column. Possibly multiple - ie. if there were 3 checks we could simply put 123|567|890 into civicrm_contribution.check_number. This feels compatible with existing stuff to me.
<td {$valueStyle}>{$form.trxn_id.html} {help id="id-trans_id"}</td> | ||
</tr> | ||
{if $email and $outBound_option != 2} | ||
<tr class="crm-contribution-form-block-is_email_receipt"> |
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 think this needs to come out of the payment block - probably above it
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.
hmm agree
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.
Ok I've raised #10777 to move that out as a prelude. Also resulted in less code duplication & a nice UI tweak that was in one place & not the other being retained
{ts}Payment Details{/ts} | ||
</div> | ||
<div class="crm-accordion-body"> | ||
{if $contribID && $payments} |
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.
Shouldn't we just determine if we are in edit mode - perhaps use Core_Action - seems like this is a round-about-way of saying that. I guess you think it should be suppressed if there are no payments because it might seem 'obvious' that there aren't any
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.
It's for 'Pending' contribution where no actual payment(s) were made. So to ensure we expose payment details block for pending contributions
OK - so the upshot here is I think we are removing too many receipt type fields. |
Hmm - maybe suppressed for me locally rather than a PR issue - let's see... |
nope - it is suppressed. I think we should move the receipt fields above the block |
@@ -246,7 +240,7 @@ | |||
{ts}Payment Details{/ts} | |||
</div> | |||
<div class="crm-accordion-body"> | |||
{if $contribID && $payments} | |||
{if $contribID && ($payments || $isPending)} |
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.
Actually this is the same as if $contribID isn't it - although I would always prefer a var like $isEditMode
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.
as $isPending is ONLY set if contribution status is Pending
so I thought why not name it so to add meaning
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.
ok I guess cancelled would be a case where it would NOT be present.
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.
yes
<div class="odd-row"> | ||
{ts 1=$entity} No payments found for this %1 record.{/ts} | ||
{if $isPending} | ||
{capture assign=payNowLive}{crmURL p='civicrm/contact/view/contribution' q="reset=1&action=update&id=`$contribID`&cid=`$contactId`&context=`$context`&mode=live"}{/capture} |
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.
is this url correct? - has view in it
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.
yup it's just a cut paste from above https://github.com/civicrm/civicrm-core/pull/10776/files#diff-c901defeafe677e3a1c2e18b793d18bcL189
@monishdeb I'm off to bed but here is where I got to with this. I think it is very nearly there! Overall I really like it. I know it's not the perfect UI that one might draw from scratch but if we avoid that as our benchmark & aim for incremental improvement here is how it fits,
As an incremental change it works & I think it should be fairly non-controversial - having said that it might be worth pinging people that I think are pretty good from a UI POV like @lcdservices @agh1 @Stoob & @colemanw - just to check it seems OK to them. It's actually not dissimilar to a part of a screen mock up I saw @jamienovick do (he had a bunch of other things going on - but this as a re-usable code chunk looked like a part of his grand plan) A lot of the things I had in this comment have now been resolved (it started out a lot longer) but there are still a few things..
It's possible we should provide a way to edit these on the contribution record & not on the payment, this should not be too obvious, perhaps an edit-in-place hidden in an accordian down the bottom. This isn't a new issue, but it becomes pertinent to discuss with this change. |
@@ -53,6 +53,14 @@ | |||
{else} | |||
{assign var='entity' value=$component} | |||
{/if} | |||
{ts 1=$entity}No payments found for this %1 record{/ts} | |||
<div class="odd-row"> | |||
{ts 1=$entity} No payments found for this %1 record.{/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.
These
will complicate translation? Better handled in CSS I think. (Is it really an odd-row
or are we using that in a different sense?)
Aside from my whitespace nitpicks above, this looks great! It might be illuminating if the issue articulates a little about the intended purpose (rather than the functional description). You know - "our neighbourhood org has a weekly promise meeting, and people complete donation process during the week", tell a bit of a story? (I see the benefit of this functionality, but don't fully understand why you'd want to record a donation before the person makes it. Help me see why?) |
</table> | ||
</fieldset> | ||
{if $showCheckNumber || !$isOnline} | ||
<tr id="checkNumber" class="crm-contribution-form-block-check_number"> |
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.
We should move this to the payment form once they are off the edit form (I'm ok with leaving that out of scope for this PR though)
@xurizaemon yeah there is a fundamental confusion here - around about 3.x we had a long discussion about the fact that people want to make multiple payments against (for example) an event. At that time there was a one to one relationship between contributions or events and we identified that you actually have 2 things in that transaction - an invoice and a payment and it was resolved that actually a contribution maps to an invoice rather than to a payment. Hence it is now possible to register someone for an event & they get one contribution against which they can make n payments. We never really updated the UI (& many code places) to reflect the changes to the data model that changed around 4.3 to reflect this interpretation of what business entity maps to what |
Removed WIP as this is open for comment rather than WIP now |
I think this looks great, and don't really have anything to add in terms of the UI. A few functionality things though (which maybe are better handled in a separate improvement PR, as some are not directly related): 1)- for non-CC-transaction payments, I think we should have the ability to delete the payment. re: @eileenmcnaughton comments concerning the shift in data structure from v4.3 -- |
To your points
Of notes above I think number 2 is the one where we probably need to confirm the spec for. So to clarify here is my proposal
|
@guanhuan any chance you can chase this up internally & see if we can unblock it - there are other bug fixes blocked by this |
@eileenmcnaughton @JoeMurray @monishdeb Sorry for slow response. I've spent some (a lot!) of time thinking about this and trying to abstract out what we are trying to achieve. The overall objective is to clearly separate out the contribution from the payment entities and trying to reflect better the 1 to many relationship between them (or should that be many to many??). I feel that (from what I can see) this PR achieves some of this under certain specific circumstances. My concern is that we are definitely only doing half of the job, and as such are leading to inconsistencies:
In reality the question here is whether to: a) See this as an improvement that does 2 or 3 out of the 10 things we want to do, perhaps well enough to put this in What I would like is that we have a really clear spec for this - a lot of what Im doing here is inferring from the screens above and the ticket, but I think a set of wireframes that covers all the screens and all the states of those screens is the correct way to attack this. I've started to do that here: https://wiki.civicrm.org/confluence/display/CRM/Separating+Contributions+and+Payments but of course this slows things down and perhaps may increase the scope of works. So what I would like to see (but understand that this may not be feasible) before this is approved:
Is that feasible? J |
So with regards to the change in scope - this issue is about progressing changes to the edit form, which will allow us to resolve some ongoing bugs / issues around payment (e.g. the 'flapping payment instrument' problem & the 'yo extra financial transactions where did you come from' problem). There is a larger scope about further changes that might be made in the future and I think your wireframes are a good step towards planning them. I broadly agree with the suggestions you have made, and some of those could be made fairly easily. I'm going to focus in on this change in my comments here because I making this incremental change is a good code, testing, & UI step forwards. I think if we are going to reject it because it doesn't do everything then we need to be clear about the ways in which it is. a) making it worse and /or I have pinged a number of specific people who I feel have good insight into UI starting from July (above) and emailed the dev-money list in July, so I have certainly tried to consult & elicit feedback. This has also been in the PR q in one form or another for most of this year. The scope of my comments is thus on the 'EDIT contribution' form. I'm going to assume any suggested changes to the 'Add contribution' or 'Add payment' form remain out of scope. On the edit form there are some specific suggestions
The following items / suggestions can stand alone from this change & be discussed separately and happen or not independent of this (although only once this has been merged or abandoned or we will find it hard to manage)
Note I don't believe anyone working on this is customer funded - I would really like it to go in because I think it moves us in the right direction and if we let this go stale again now I think we will be starting from scratch again on this piece of the puzzle. |
CRM/Contribute/Form/Contribution.php
Outdated
@@ -1453,6 +1457,19 @@ protected function submit($submittedValues, $action, $pledgePaymentID) { | |||
if (!empty($this->_payNow)) { | |||
$this->_params['contribution_id'] = $this->_id; | |||
} | |||
// Since we are hiding the payment details block in edit mode, |
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.
This smells bad to me. It's pulling in one value for payment instrument and check number when there may be many associated with a contribution. We should eliminate that expectation from the values submitted when editting a contribution.
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.
yep agree - the bao should load them if it needs them. There is a bit of an issue in some of the BAO functions where they are not properly interpretting 'this var is not in $params so we should understand it is not being changed'.
(I'm not going to try to improve this ATM as I think the PR is more seriously blocked at the moment)
I think the contribution status should remain out of scope for this PR. For me, it's something I've wanted for a few years but it was too big to tackle without a good budget and a lot of patience for community interactions. Looking over Eileen's latest comments, I'm not sure that anything more is required of this PR before merging, except to resolve branch conflicts on the .tpl due to delay in merging I presume. |
@JoeMurray apart from this being stale I'd kinda given up on it as blocked by @jamienovick From my point of view the minimum to get it merged would be
I've been thinking this could go in an extension as getting it into core is too difficult. We would want to freeze developing various areas of code in core (which would be confusing) since we'd be moving the primary technique (not having a many to one form that pretends to be a one to one form) for fixing code issues relating to partial payments being an outside core thing, and we should enable the new one by default. Perhaps @colemanw you want to make a call |
@monishdeb I got a further comment from @jamienovick saying "Hi @Eileen sorry I didnt see this - I did leave a last comment to say go ahead if you thought it was ok and whilst it stops short of what I think we need I guess it does move us on the pathway there. If we did want to put it on hold however we could include it as part of a bigger piece of work to really look at splitting payments and contributions. We are now some way towards documenting this. See here: https://civicrm.atlassian.net/wiki/spaces/PPI/pages/2261058/1.+Split+Contribution+and+Payment+fully. It would be great to get your feedback on this as we work thought it." I think we should revisit this. I think it would be good to touch this file |
accfc36
to
fd13bfb
Compare
Actually, I would leave it there even if fully paid or overpaid, as clients report sometimes receiving a second cheque in mail for an invoice, sometimes one that has since been modified. |
@JoeMurray I don't know off the top of my head whether the 'Add payment' form copes OK with that or not - not that part is in #11432 which I think we should review & merge before assessing this |
@eileenmcnaughton it's strange there aren't any merge conflicts after I merged #11432 . Isn't that PR created after pulling out most of the changes from current PR ? |
I rebased it over the top - will re-rebase it now |
fd13bfb
to
4c131fa
Compare
@eileenmcnaughton I am getting a notice error on backoffice contribution edit form I have prepared a patch for it, considering diff --git a/CRM/Contribute/Form/AbstractEditPayment.php b/CRM/Contribute/Form/AbstractEditPayment.php
index c09e51d..f2ab9c0 100644
--- a/CRM/Contribute/Form/AbstractEditPayment.php
+++ b/CRM/Contribute/Form/AbstractEditPayment.php
@@ -707,9 +707,10 @@ WHERE contribution_id = {$id}
* Block title.
*/
protected function assignPaymentInfoBlock() {
- $paymentInfo = CRM_Contribute_BAO_Contribution::getPaymentInfo($this->_id, $this->_component, TRUE);
+ $component = empty($this->_component) ? $this->_context : $this->_component;
+ $paymentInfo = CRM_Contribute_BAO_Contribution::getPaymentInfo($this->_id, $component, TRUE);
$title = ts('View Payment');
- if (!empty($this->_component) && $this->_component == 'event') {
+ if (!empty($component) && $component == 'event') {
$info = CRM_Event_BAO_Participant::participantDetails($this->_id);
$title .= " - {$info['title']}";
}
diff --git a/CRM/Contribute/Form/Contribution.php b/CRM/Contribute/Form/Contribution.php
index 70306d2..58237af 100644
--- a/CRM/Contribute/Form/Contribution.php
+++ b/CRM/Contribute/Form/Contribution.php
@@ -227,6 +227,9 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP
$this->assign('action', $this->_action);
+ $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
+ $this->assign('context', $this->_context);
+
// Get the contribution id if update
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
if (!empty($this->_id)) {
@@ -235,9 +238,6 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP
$this->assign('isUsePaymentBlock', TRUE);
}
- $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
- $this->assign('context', $this->_context);
-
$this->_compId = CRM_Utils_Request::retrieve('compId', 'Positive', $this);
$this->_compContext = CRM_Utils_Request::retrieve('compContext', 'String', $this); |
@monishdeb I have been thinking about this - on one hand I think it's an important step forwards. I don't think we can properly handle issues like https://issues.civicrm.org/jira/browse/CRM-21756 without resolving the ambiguity between payment & amount due on back office forms and I feel slightly nauseous that we may have spent dozens of hours fixing similar bugs that may not have been required had we bedded this in. On the other hand - this went cold in Sep last year & I think both of us have been reluctant to put the work in to get ourselves mentally back into the space of this enough to get it finished (I would say there is at least a day's work just to mentally 'uncold' it). However I also sense that this could be merged with an on/off switch to get us past our nerves a little. ie. unless $isUsePaymentBlock', TRUE is assigned to the template I think the existing one contribution-to-one payment block will appear & if it is the multiple payment block will appear. I'm inclined to leverage this & add a temporary setting is_display_non_legacy_payment_block & put in a call back that sets it to TRUE is isDevelopment. After JMA have deployed it in production for a few cycles we can look at changing more aggressively. The immediate impact of the change will be in developer mode as it will change how we address bugs but eventually we'll need to make it compulsory. |
@monishdeb please make this a priority in coming days. Thx! |
Ooops, sorry for temporarily closing. |
This has been heavily discussed - including on dev list. I followed @agh1 suggestion here https://lab.civicrm.org/dev/financial/issues/3 and emailed dev list to say that this would be merge once the PR is cut, with the option of reverting if people hit issues in the nearly 2 months until release |
@Monish this is the portion of #10729 that replaces the PaymentDetails section of the Contribution form. I've put it in this PR for discussion but given the pretty pictures already on that PR we should probably take what we agree back over there