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-21198 Update membership status appropriately when adding a payment #11006

Merged
merged 1 commit into from
Sep 27, 2017

Conversation

eileenmcnaughton
Copy link
Contributor

@eileenmcnaughton eileenmcnaughton commented Sep 20, 2017

Overview

Per #10999 this updates a membership when a payment is added to the contribution, leading to the contribution being completed.

Before

Adding a payment to a partially paid contribution with a membership will cause the membership to be completed but the membership will remain pending. Screencast:
p-membership-before

After

The membership will be updated to 'new' (as appropriate) when the contribution is completed via the record payment form. This is happening in the BAO so the (underused) payment api would also be fixed in this scenario. Screencast:
p-membership-after

Technical Details

This is primarily an extraction of code from completeOrder which is then also used for this path. Hopefully, over time we will consolidate further but we have been extracting & tidying up completeOrder & adding testing since 4.2 so it is not straightforward

Comments

@monishdeb -this is now a replacement for the previous PR - it holds the collaborated changes + the test with the parts that relate to not-yet-reviewed fixes commented out


@seamuslee001
Copy link
Contributor

Jenkins re test this please

1 similar comment
@seamuslee001
Copy link
Contributor

Jenkins re test this please

@seamuslee001
Copy link
Contributor

just noting that i have had to stop the Jenkins Job twice because it seems to get into a loop

@monishdeb
Copy link
Member

Ok, I am taking this PR form here.

@monishdeb
Copy link
Member

@eileenmcnaughton I have updated the PR, can you please check now?

@eileenmcnaughton
Copy link
Contributor Author

I just fixed the style error & @seamuslee001 I tried re-running tests locally to see if it would loop but both
CRM_Core_Payment_AuthorizeNetTest & CRM_Core_Payment_AuthorizeNetIPNTest completed

@monishdeb
Copy link
Member

@eileenmcnaughton I think what @seamuslee001 have earlier reported was due to wrong order of updateMembershipBasedOnCompletionOfContribution(...) arguments which I fixed in later commits. The test build passed thereafter.

@eileenmcnaughton
Copy link
Contributor Author

@monishdeb I've squashed it all in now. I also brought across the test & commented out the lines that don't pass (relate to the other fixes). I was able to see the test fail when the membership type was not being updated and pass with this patch when it was being updated

@@ -76,8 +76,8 @@ public function tearDown() {
public function testInvoiceSentOnIPNPaymentSuccess() {
$this->enableTaxAndInvoicing();

$pendingStatusID = CRM_Core_OptionGroup::getValue('contribution_status', 'Pending', 'name');
$completedStatusID = CRM_Core_OptionGroup::getValue('contribution_status', 'Completed', 'name');
$pendingStatusID = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Pending');
Copy link
Contributor Author

Choose a reason for hiding this comment

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

not sure why this was not failing the tests on jenkins. It did locally

Copy link
Member

Choose a reason for hiding this comment

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

hmmm strange

$dao->free();

// Unclear why this is here but this function is overloaded by repeattransaction.
if ($contributionStatus === 'Pending') {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

simplification of this IF is the only thing changed in the extraction

@eileenmcnaughton eileenmcnaughton changed the title Towards CRM-21198 Extract membership update function CRM-21198 Update membership status appropriately when adding a payment Sep 26, 2017
@monishdeb
Copy link
Member

Hopefully it will pass this time 😄👍

@monishdeb
Copy link
Member

@colemanw can you review and merge this PR?

@eileenmcnaughton
Copy link
Contributor Author

@colemanw for clarity - in the review process I reworked the PR & then @monishdeb added to that & we collaborated in the review process to get to this version - hence I can no longer merge the result of the review process.

@colemanw
Copy link
Member

Looks good. Thanks for all your hard work Eileen & Monish 🥇


unset($dates['end_date']);
$membershipParams['status_id'] = CRM_Utils_Array::value('id', $calcStatus, 'New');
//we might be renewing membership,
Copy link
Contributor

Choose a reason for hiding this comment

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

So for a renewing member, their status will change from pending to current once the partial payment is completed. Correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes... please test...

Copy link
Contributor

Choose a reason for hiding this comment

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

@eileenmcnaughton Yes it works as expected.

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.

7 participants