Usually recording the payment for the membership's contribution means :
Activating the membership by changing its status from pending to active.
Renewing the membership by extending its end_date.
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.
After
Recording a payment for a partially paid contribution will not renew its related membership.
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.
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.
After
Recording a payment for a partially paid contribution will not renew its related membership.
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 notis_pay_later
with checking if the contribution isPartially 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.