Skip to content

Commit

Permalink
CIWEMB-438: Show future payment schedule for active payment plans only
Browse files Browse the repository at this point in the history
  • Loading branch information
omarabuhussein committed Aug 7, 2023
1 parent 685e053 commit 9499af2
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions CRM/MembershipExtras/Hook/PageRun/ContributionRecurViewPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ private function modifyPageElements() {

private function getFuturePaymentSchemeScheduleIfExist($recurId) {
try {
if (!$this->isActivePaymentPlan($recurId)) {
return NULL;
}

$paymentPlanScheduleGenerator = new CRM_MembershipExtras_Service_PaymentScheme_PaymentPlanScheduleGenerator($recurId);
$paymentsSchedule = $paymentPlanScheduleGenerator->generateSchedule();
array_walk($paymentsSchedule['instalments'], function (&$value) {
Expand All @@ -44,4 +48,12 @@ private function getFuturePaymentSchemeScheduleIfExist($recurId) {
}
}

private function isActivePaymentPlan($recurId) {
return \Civi\Api4\ContributionRecur::get()
->addSelect('payment_plan_extra_attributes.is_active')
->addWhere('id', '=', $recurId)
->execute()
->column('payment_plan_extra_attributes.is_active')[0];
}

}

0 comments on commit 9499af2

Please sign in to comment.