compucorp / uk.co.compucorp.membershipextras

Membership Extras for CiviCRM
Other
5 stars 8 forks source link

MAE-619: Fix error with extra amounts being added to total contribution amount #405

Closed olayiwola-compucorp closed 3 years ago

olayiwola-compucorp commented 3 years ago

Overview

This PR ensures that Recurring contribution amount is correct after adding a line item in manage installments view of annual payment plan and that has auto renewal

Before

before-contrib

After

after-contrib

Technical Details

When calculating new total amount for recurring contribution, ensure that only amount from line items with end_dates are included (Given that the payment has one or no installment). same condition is applied to every other part of the code where total recurring contribution amount is calculated.

$installments = CRM_Utils_Array::value('installments', $this->recurringContribution, 0);
if ($installments <= 1) {
    $conditions['end_date'] = ['IS NULL' => 1];
}
omarabuhussein commented 3 years ago

Just to add some details here, if subscription line item for single installment (annual) payment plan has an end date, then it means that it is for a previous term, if not then it means it is for the current term, we do that because in annual payment plan we don't create new payment plan after renewal (as it is the case for monthly or quarterly payment plans), but rather keep using the existing one, so the end date on the subscription line item help to identify which subscription line items are current and which belong to an old term.

olayiwola-compucorp commented 3 years ago

Merging this PR after passing QA