From 9499af25787031b589274ff8c88a489858722c63 Mon Sep 17 00:00:00 2001 From: Omar Hussein Date: Mon, 7 Aug 2023 17:31:33 +0100 Subject: [PATCH] CIWEMB-438: Show future payment schedule for active payment plans only --- .../Hook/PageRun/ContributionRecurViewPage.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/CRM/MembershipExtras/Hook/PageRun/ContributionRecurViewPage.php b/CRM/MembershipExtras/Hook/PageRun/ContributionRecurViewPage.php index 479d06ee..d8bde576 100644 --- a/CRM/MembershipExtras/Hook/PageRun/ContributionRecurViewPage.php +++ b/CRM/MembershipExtras/Hook/PageRun/ContributionRecurViewPage.php @@ -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) { @@ -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]; + } + }