Set new inactive statuses as 'Chargeback' does not exist on new installs and that...
authorMatthew Wire (MJW Consulting) <mjw@mjwconsult.co.uk>
Sat, 1 Jun 2019 17:09:07 +0000 (18:09 +0100)
committerMatthew Wire (MJW Consulting) <mjw@mjwconsult.co.uk>
Sat, 1 Jun 2019 17:09:07 +0000 (18:09 +0100)
CRM/Contribute/BAO/ContributionRecur.php

index a416a9573f2031f630ffaa4deec4b5f363d66a68..5f45d1868f42ea8d12ba68fb4423ed383cc7dabd 100644 (file)
  */
 class CRM_Contribute_BAO_ContributionRecur extends CRM_Contribute_DAO_ContributionRecur {
 
-  /**
-   * Array with statuses that mark a recurring contribution as inactive.
-   *
-   * @var array
-   */
-  private static $inactiveStatuses = ['Cancelled', 'Chargeback', 'Refunded', 'Completed'];
-
   /**
    * Create recurring contribution.
    *
@@ -276,15 +269,14 @@ class CRM_Contribute_BAO_ContributionRecur extends CRM_Contribute_DAO_Contributi
       'details' => CRM_Utils_Array::value('processor_message', $params),
     ];
 
-    $contributionStatus = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
-    $canceledId = array_search('Cancelled', $contributionStatus);
+    $cancelledId = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_ContributionRecur', 'contribution_status_id', 'Cancelled');
     $recur = new CRM_Contribute_DAO_ContributionRecur();
     $recur->id = $recurId;
-    $recur->whereAdd("contribution_status_id != $canceledId");
+    $recur->whereAdd("contribution_status_id != $cancelledId");
 
     if ($recur->find(TRUE)) {
       $transaction = new CRM_Core_Transaction();
-      $recur->contribution_status_id = $canceledId;
+      $recur->contribution_status_id = $cancelledId;
       $recur->start_date = CRM_Utils_Date::isoToMysql($recur->start_date);
       $recur->create_date = CRM_Utils_Date::isoToMysql($recur->create_date);
       $recur->modified_date = CRM_Utils_Date::isoToMysql($recur->modified_date);
@@ -333,7 +325,7 @@ class CRM_Contribute_BAO_ContributionRecur extends CRM_Contribute_DAO_Contributi
     else {
       // if already cancelled, return true
       $recur->whereAdd();
-      $recur->whereAdd("contribution_status_id = $canceledId");
+      $recur->whereAdd("contribution_status_id = $cancelledId");
       if ($recur->find(TRUE)) {
         return TRUE;
       }
@@ -933,13 +925,12 @@ INNER JOIN civicrm_contribution       con ON ( con.id = mp.contribution_id )
   }
 
   /**
-   * Returns array with statuses that are considered to make a recurring
-   * contribution inactive.
+   * Returns array with statuses that are considered to make a recurring contribution inactive.
    *
    * @return array
    */
   public static function getInactiveStatuses() {
-    return self::$inactiveStatuses;
+    return ['Cancelled', 'Failed', 'Completed'];
   }
 
   /**