compucorp / uk.co.compucorp.membershipextras

Membership Extras for CiviCRM
Other
5 stars 8 forks source link

MAE-522: Prevent extending membership end date #383

Open ahed-compucorp opened 3 years ago

ahed-compucorp commented 3 years ago

Overview

Usually recording the payment for the membership's contribution means :

We have a use case when the admin adds a new line items to a completed contribution and that will change its status to "Partially paid", but recording the payment for that contribution will trigger the renewal membership processing if the contribution was related to a membership.

Before

Recording a payment for a partially paid contribution will renew its related membership.

Peek 2021-06-02 11-33

After

Recording a payment for a partially paid contribution will not renew its related membership.

Peek 2021-06-02 11-31

Technical Details

The method updateMembershipBasedOnCompletionOfContribution at Contribution.php#L4793 does not handle the case when recording another payment for the membership's contribution.

At Compucorp, we use the "biz.jmaconsulting.lineitemedit" extension to add and edit the line items.

Adding a line item changes the contribution status to "Partially Paid" and recording a payment for an active membership's contribution will renew it by default and extend its end_date, but this is undesirable behaviour and this PR will prevent it.

At first, I tried to check the MembershipPayment but that wasn't right because the CiviCRM will create it during the membership creation or renewing and not during the payment recording. Then I checked if the membership was active and not is_pay_later with checking if the contribution is Partially paid. Lastly, I tried to check if the contribution's paid amount is larger than the membership fee , but I couldn't think of a use case that will need it so I removed it from this PR.

Comments

It was a bit tricky to decide where to send this PR, let me see what you think about it.