-
-
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-19594 Wrong membership updated #9390
Conversation
eileenmcnaughton
commented
Nov 15, 2016
•
edited by civicrm-builder
Loading
edited by civicrm-builder
- CRM-19594: Wrong Membership Updated
* @param $isEmailReceipt | ||
* @return mixed | ||
*/ | ||
public static function handlePledge(&$form, $params, $contributionParams, $pledgeID, $contribution, $isEmailReceipt) { |
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 all just an extraction - moving a chunk of code out of the main function
@@ -1445,6 +1460,7 @@ protected function postProcessMembership( | |||
} | |||
} | |||
|
|||
$membershipParams['skipLineItem'] = 1; |
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.
ie don't add line items while doing contribution
@@ -321,6 +321,9 @@ public static function create(&$params, &$ids, $skipRedirect = FALSE, $activityT | |||
); | |||
} | |||
|
|||
if (empty($params['line_item']) && !empty($params['membership_type_id']) && empty($params['skipLineItem'])) { |
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.
Moved here from api
$membership->id, | ||
$params['line_item'], | ||
CRM_Utils_Array::value('contribution', $params), | ||
'civicrm_membership' |
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.
pass in entity
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 we should check if this does something wierd with a multi-row set
@@ -1835,48 +1844,20 @@ public static function renewMembership($contactID, $membershipTypeID, $is_test, | |||
// CRM-15475 | |||
array_search('Cancelled', CRM_Member_PseudoConstant::membershipStatus(NULL, " name = 'Cancelled' ", 'name', FALSE, TRUE)), | |||
))) { | |||
$membership = new CRM_Member_DAO_Membership(); |
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.
Instead of bypassing membership.create call it with basic params, including the contribution
@ginkgomzd I was able to replicate the issue in a test - this fixes the test in the 2 scenarios covered. Really we want more of them.. |
c3ec81e
to
dfcdd27
Compare
dfcdd27
to
f325b96
Compare
f325b96
to
9d8ef4b
Compare
There are several but I have only touched the one where I was already working on the test coverage
9d8ef4b
to
f69a9ac
Compare
@ginkgomzd I'll need you to QA this before I can merge it. I'm worried about what happens to the line items under different combos - I have only ensured memberships are good |
sorry - single item membership pricesets |
6759a09
to
4309bfd
Compare
4309bfd
to
16f3bd0
Compare
Per the request of @eileenmcnaughton, I'm also taking a look at this to see if I can extend test coverage to handle the other cases she mentioned - but this is a lot to wrap my head around. I'll report in in a few hours if I've made any progress. |
test this please |
I tried extending the test I tested that by adding these 3 lines to the bottom of the test:
If someone confirms that this is what's happening, it seems like it's not really possible to write assertions that pass in this test without fixing that bug first. |
Just added this to Mattermost - but pasting it bottom-line of that here as well: I just had a look at public function testSubmitMembershipBlockIsSeparatePayment() { and: a) good news is that on a new civibuild dmaster via GUI - doing separate Membership Payment + Contribution produces: 2 entries in the civicrm_contribution and 2 entries in civicrm_line_item; so it's working as advertised. However b) when I run this test however - I get: 2 correct entries in the civicrm_contribution and only get a line_item entry for the Membership Amount and it's $1 (and it should be $2). So this test is quite broken - at least on the contribution line_item level. The actual CiviCRM code is correct though - it's really just the test that's failing; the way in which it creates the Contributions does not mimic how in the real code base these are (correctly) created. |
604f8ea
to
632196e
Compare
civicrm_contribution looks good: | 3581 | 7 | 1 | 19 | 1 | 2016-11-28 21:42:19 | NULL | 3.33 | 0.00 | 3.33 | A9535988:1480387340 | c0c497b9d997690fb413fa32cd47e5e2-2 | CAD | NULL | 0 | 2016-11-28 21:42:21 | NULL | Online Contribution: | 3582 | 7 | 2 | 19 | 1 | 2016-11-28 21:42:20 | NULL | 10.00 | 0.00 | 10.00 | A9535986:1480387339 | 35a0de91f22255b56427a0e79a123304 | CAD | NULL | 0 | 2016-11-28 21:42:21 | NULL | Online Contribution: civicrm_line_item does not: 3582: was $10 - civicrm_line_item for contribution_id = 3582 has $3.33 - and has it as an add on Donation - financial_type id = 1 (Donation) should be Member Dues. MariaDB [civicrm_semperit_com]> select * from civicrm_line_item where contribution_id=3581; MariaDB [civicrm_semperit_com]> select * from civicrm_line_item where contribution_id=3582; |
Let me know if this is helpful and/or if you'd like me to look at other bits. |
@KarinG how are you transacting this? Contribution page configured with membership + separate payment? |
Or price set? |
So, you have configured it as a price set on a contribution page? |
No in the Configuration it's: Memberships tab: Membership Section Enabled and |
So not using any Price Sets [not in the Memberships tab and not in the Contribution tab of the Contribution Page config] |
Whoever added that separate payment option has a lot to answer for - I swear it has cost us high-five digits over the years! |
I am successfully using it for a 4.6 project though: College of HCP: Membership fee + Late fee (and I have some code that then automatically decides the correct Late fee based on date/time and hides the other options) - and there it's working on a Contribution and Receipting level [not worried about line_items or financial_items for this project]; |
Not even sure if this PR broke that - or if this is completely different. |
It could well be different - but I'll look anyway |
The receipt issue for sure is a regression [something that was working in 4.6] - but this may not be the issue here or caused by this PR. Every time I think I understand a few more things about CiviContribute I prove myself wrong... |
@KarinG I have merged a fix into the rc - hopefully it works now.... |
Just checked my previous testing notes and I hadn't re-tested with "Separate Membership Payment" ticked after applying #9449, so it looks like that re-broke it. Have now done that test, with #9449 but without #9464 and confirmed @KarinG's results: Re-testing #9449 without #9464
Summary
Testing with latest RC branch code, #9464 merged
Summary Gory details 1 contact, id 218 1 membership, id 114 2 membership_log:
2 contributions, id 112 & 113 1 membership_payment:
2 line_items:
4 financial_trxn: Checking other memberships:
|
Hmm, I didn't receive email receipts so didn't see that issue. Something up with mail on localhost. :-( |
For anyone still on or about to go live on 4.7.13 (and unable/unwilling to upgrade at the very last minute), is there a workaround or something that can be done to avoid this? It sounds like it happens when membership IDs & contribution IDs collide? Perhaps bump up the contribution ID sequence as a workaround? |
@litespeedmarc yes, the updating of wrong memberships happens when membership IDs & contribution IDs collide. Bumping up the contribution ID sequence would I think avoid this, as a workaround. I think line items could still get created with incorrect entity_ids even so, with entity_table = 'civicrm_membership' but with entity_id = the contribution id instead of the membership id. But if there's no membership with that id, at least it avoids also updating the wrong membership. |
I think you might still get line item inaccuracies. I would encourage you to test the rc. |
@KarinG @davejenx I'm starting to think the wrong email details on separate payment issue might be present in 4.7.13 rather than being a 4.7.14 regression - can either of you confirm that? If so I'm inclined to NOT attempt to fix this for 4.7.14 but give it more time in 4.7.15 - the code seems particularly gnarly and if it's actually a NEW can of worms I might not open it just yet |