Fix recalculation of dates on pledge
authorJitendra Purohit <jitendra@fuzion.co.nz>
Tue, 6 Apr 2021 09:42:02 +0000 (15:12 +0530)
committerJitendra Purohit <jitendra@fuzion.co.nz>
Tue, 6 Apr 2021 09:42:02 +0000 (15:12 +0530)
CRM/Pledge/BAO/Pledge.php

index 2f647e153bd0957368df9d4b84cf959efb3be2d9..63078610fd4893439d0913d378c095c6ed3d9e6a 100644 (file)
@@ -128,6 +128,7 @@ class CRM_Pledge_BAO_Pledge extends CRM_Pledge_DAO_Pledge {
       $params = array_merge($defaults, $params);
     }
 
+    $isRecalculatePledgePayment = self::isPaymentsRequireRecalculation($params);
     $transaction = new CRM_Core_Transaction();
 
     $paymentParams = [];
@@ -172,10 +173,10 @@ class CRM_Pledge_BAO_Pledge extends CRM_Pledge_DAO_Pledge {
     }
 
     // skip payment stuff in edit mode
-    if (empty($params['id']) || self::isPaymentsRequireRecalculation($params)) {
+    if (empty($params['id']) || $isRecalculatePledgePayment) {
 
       // if pledge is pending delete all payments and recreate.
-      if (!empty(empty($params['id']))) {
+      if ($isRecalculatePledgePayment) {
         CRM_Pledge_BAO_PledgePayment::deletePayments($pledge->id);
       }