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-20889 : Toggle check_number field on backoffice form as payment form fields #10680

Merged
merged 4 commits into from
Sep 13, 2017

Conversation

monishdeb
Copy link
Member

@monishdeb monishdeb commented Jul 17, 2017

@monishdeb
Copy link
Member Author

@eileenmcnaughton can you review this patch about introducing check_number as payment field ?

@eileenmcnaughton
Copy link
Contributor

I just gave it a quick skim and I approve it from a code point of view - it is an improvement and 64 is a fine score!

It's still pending actual testing - looks like it affects all back office forms that take payments

@jitendrapurohit
Copy link
Contributor

Tested this changes on back office contribution, membership, pledge and event forms. Found two issues -

  1. Contribution -
    a. Pay using credit card or some other instrument but not check. Save.
    b Edit the contribution record. Check number textbox is displayed even-though credit card is selected in payment_instrument_id field.

image

  1. Events -
    a. Add an event registration for a contact using check or any method. Save.
    b. Click Edit form. Payment section is not shown on this page but Check number is displayed as it is.

@monishdeb
Copy link
Member Author

@jitendrapurohit I have fixed #2 but for point #1, as per discussion with Eileen here I am going to replace the payment details section with a list of transactions on backoffice contribution edit form. As per the new spec, the payment fields will be populated on new payment edit form. So, in my opinion, we should skip #1 or else we need to include the patch of current PR as a part of CRM-20610 fix.

@eileenmcnaughton am I right?

@monishdeb
Copy link
Member Author

Jenkin test this please

@eileenmcnaughton
Copy link
Contributor

@monishdeb I think you are saying the payment form should not show up at all on the edit page (which I agree with) - but we can't merge this PR as is I don't think since it is loading with wrong info (from @jitendrapurohit's review )

@monishdeb
Copy link
Member Author

@eileenmcnaughton in order to load correct info that involves loading the values of card_number and card_type_id as default set on respective payment fields (in this case), we need to fetch the latest transaction (i.e. the SELECT ft.* FROM financial_trxn ft WHERE eft.entity_id = <contribution id> AND eft.financial_trxn_id = ft.id ) . Which I did on #10386 but as per the new spec that we discussed earlier on MM I need to revert that change on #10386. So I am not sure if we need to bring that fix again for this PR in order to resolve the #1 , What ya say?

@eileenmcnaughton
Copy link
Contributor

@monishdeb I feel like this is a good code improvement - it removes spaghetti & the UI is more consistent, and can stand alone from other changes.

I tried looking at the issue @jitendrapurohit raised & it can be fixed (at least on contribution form) like this

--- a/CRM/Contribute/Form/AbstractEditPayment.php
+++ b/CRM/Contribute/Form/AbstractEditPayment.php
@@ -516,7 +516,7 @@ WHERE  contribution_id = {$id}
       }
       $this->assignProcessors();
       $this->assignBillingType();
-      CRM_Core_Payment_Form::setPaymentFieldsByProcessor($this, $this->_paymentProcessor, FALSE, TRUE, CRM_Utils_Request::retrieve('payment_instrument_id', 'Integer'));
+      CRM_Core_Payment_Form::setPaymentFieldsByProcessor($this, $this->_paymentProcessor, FALSE, TRUE, CRM_Utils_Request::retrieve('payment_instrument_id', 'Integer', $this));
     }
     catch (CRM_Core_Exception $e) {
       CRM_Core_Error::statusBounce($e->getMessage());
diff --git a/CRM/Contribute/Form/Contribution.php b/CRM/Contribute/Form/Contribution.php
index c471233..505949d 100644
--- a/CRM/Contribute/Form/Contribution.php
+++ b/CRM/Contribute/Form/Contribution.php
@@ -550,7 +550,8 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP
       $paneNames[ts('Premium Information')] = 'Premium';
     }
 
-    if (CRM_Core_Payment_Form::buildPaymentForm($this, $this->_paymentProcessor, FALSE, TRUE, $this->getDefaultPaymentInstrumentId()) == TRUE) {
+    $this->payment_instrument_id = CRM_Utils_Array::value('payment_instrument_id', $defaults, $this->getDefaultPaymentInstrumentId());
+    if (CRM_Core_Payment_Form::buildPaymentForm($this, $this->_paymentProcessor, FALSE, TRUE, $this->payment_instrument_id) == TRUE) {
       if (!empty($this->_recurPaymentProcessors)) {
         $buildRecurBlock = TRUE;
         if ($this->_ppID) {

@eileenmcnaughton
Copy link
Contributor

(I'm not 100% sure that there isn't a better way that involves less double-setting but I think that is too much scope creep here)

@eileenmcnaughton
Copy link
Contributor

Note the payment details form replacement is currently pending further review by @guanhuan & @jamienovick so we need to make this one work by itself before we can merge

@eileenmcnaughton
Copy link
Contributor

Also - I couldn't reproduce the issue on the event form after applying the patch above.

(note I didn't put the patch as a commit because I want to be able to merge the patch once it is correct & so I can't 'taint' it by adding code to it)

@eileenmcnaughton
Copy link
Contributor

@monishdeb I feel like if you make the changes per my comment above then we can ping @jitendrapurohit to confirm it resolves his issue & merge this?

@monishdeb
Copy link
Member Author

Thanks @eileenmcnaughton for the patch, I have updated the PR with it. After the fix, it correctly shows the payment fields w.r.t chosen payment method. However, it doesn't prefill the fields with respective default values, which I think won't matter much as per new UI changes.

@jitendrapurohit would you like to retest the latest patch, which addresses both the issues you raised. Thanks!

@eileenmcnaughton
Copy link
Contributor

test this please

@jitendrapurohit
Copy link
Contributor

@monishdeb Thanks for the update. Though the input field have been fixed, the header is still shown as "Check Information" for credit card fields. To see this yourself, use the same steps as mentioned in point#1 of #10680 (comment)

image

@eileenmcnaughton
Copy link
Contributor

Odd - it should be getting the right label from
/**

  • Get the name of the payment type.
  • @return string
    */
    public function getPaymentTypeLabel() {
    return CRM_Core_PseudoConstant::getName('CRM_Contribute_BAO_Contribution', 'payment_instrument_id', $this->getPaymentInstrumentID());
    }

@monishdeb
Copy link
Member Author

monishdeb commented Sep 13, 2017

@eileenmcnaughton that's because we are setting the $paymentInstrumentID in $paymentProcessor['object']['paymentInstrumentID'] and we are NOT calling the getPaymentTypeLabel(...) on that object instance. Here's my fix for that b3453b5

Copy link
Contributor

@jitendrapurohit jitendrapurohit left a comment

Choose a reason for hiding this comment

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

All noted issues have been fixed now. Thanks @monishdeb @eileenmcnaughton

@eileenmcnaughton
Copy link
Contributor

Thanks for the review @jitendrapurohit.

I'm going to merge this based on Jitendra's testing. I would note this is a clear code improvement & it is a code simplification we have been inching towards for some time.

@monishdeb + 14 -75 = gold star :-)

Thanks for your work on this.

@eileenmcnaughton eileenmcnaughton merged commit db3a540 into civicrm:master Sep 13, 2017
@monishdeb monishdeb deleted the CRM-20889 branch September 14, 2017 05:57
@monishdeb
Copy link
Member Author

Thanks, @jitendrapurohit @eileenmcnaughton for reviewing it
Yay 😄

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