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

WIP Minor cleanup of Membership/Renewal form classes #12651

Conversation

mattwire
Copy link
Contributor

@mattwire mattwire commented Aug 13, 2018

Overview

Ref #12695 for the email receipt cleanup

  • Non-functional cleanup to Membership/Renewal form classes to extract a function and move them a tiny bit closer together.

Before

Less maintainable code.

After

Slightly more maintainable code.

Comments

@eileenmcnaughton Maybe another one for you? But also good if @agileware were to take a look given their interest in fixing renewal issues.

@civibot
Copy link

civibot bot commented Aug 13, 2018

(Standard links)

@eileenmcnaughton
Copy link
Contributor

@mattwire I don't really trust myself to review a commit like the second one without missing something :-( We've had a few things missed on refactors of late so I'd rather break it down

@@ -1496,16 +1497,15 @@ public function submit() {
$params['trxn_id'] = CRM_Utils_Array::value('trxn_id', $result);
$params['is_test'] = ($this->_mode == 'live') ? 0 : 1;
if (!empty($formValues['send_receipt'])) {
$params['receipt_date'] = $now;
$params['receipt_date'] = $params['receive_date'];
Copy link
Contributor

Choose a reason for hiding this comment

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

@mattwire I went through the changes in this file (only) on top of #12642 which changes the same file & this line is the only one in this file I have a reservation about - I think it should be date('YmdHis'); which is less confusing.

I can pull the changes you have made to this file into #12642 if you want to review that & then I'll try to make sense of the changes in MembershipRenewal. The early ones seem pretty straightforward but the function extraction should probably stand alone

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@eileenmcnaughton I've reviewd #12642 When it is merged I'll update this PR

// a function this form shared with other forms.
$membershipSource = NULL;
if (!empty($this->_params['membership_source'])) {
$membershipSource = $this->_params['membership_source'];
}

$isPending = ($this->_params['contribution_status_id'] == 2) ? TRUE : FALSE;
$isPending = ($this->_params['contribution_status_id'] == $pendingContributionStatusId) ? TRUE : FALSE;
Copy link
Contributor

Choose a reason for hiding this comment

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

@mattwire the other is merged & this can be rebased. I've checked all the changes down to this line so far & am OK with them so if you pull those into one PR I can merge that quickly

@eileenmcnaughton
Copy link
Contributor

@mattwire I see now that you have refactored emailReceipt into it's own function (which is good). You have made it static which I think is in order to sync with the Membership.

But, I'd like to propose that the function in Membership is pretty dire. It was obviously made static to share code with the CRM_Batch_Form_Entry class - which also calls it. But I would say 2/3 of the code in that function is not genuinely shared.

So, instead of copying that approach what about we start to defang that approach - eg.

2073036

Which then lends itself to moving routines used by the 2 membership classes but not by the BatchEntry class outside of that function - e.g f73ad85


list($renewMembership) = CRM_Member_BAO_Membership::processMembership(
Copy link
Contributor

Choose a reason for hiding this comment

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

This variable renaming is causing a lot of noise & would be better done before or after the other changes IMHO (I'm not 100% sure it's better TBH, although I see renew !== renewed which I would be more keen on)

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, I'll update. I figured that it would be easier to merge Membership/MembershipRenewal forms in the future if the variable names match - and $renewMembership is a membership array that is not necessarily a renewal.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Rename now in #12798

@mattwire mattwire force-pushed the membershiprenew_twopaymentprocessorfields branch 2 times, most recently from 89da241 to 1216d24 Compare August 28, 2018 10:58
@mattwire mattwire changed the title Minor cleanup of Membership/Renewal form classes WIP Minor cleanup of Membership/Renewal form classes Aug 28, 2018
@eileenmcnaughton
Copy link
Contributor

@mattwire this one is stale now so I'll close it out - not sure what pieces are left of this work

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.

3 participants