CRM-16835 Added fix to allow contributions with Partially paid status to be Completed
authorEdsel <edsel.lopez@jmaconsulting.biz>
Mon, 13 Jul 2015 11:30:53 +0000 (17:00 +0530)
committerEdsel <edsel.lopez@jmaconsulting.biz>
Mon, 13 Jul 2015 11:30:53 +0000 (17:00 +0530)
----------------------------------------
* CRM-16835: Support changing contributions with partially paid status to completed.
  https://issues.civicrm.org/jira/browse/CRM-16835

CRM/Contribute/BAO/Contribution.php

index 534b387ced444fe55747121837bb25cc3c7db461..28973aec7fb65548d5e3e49d03dc9d6eb87a2b5c 100644 (file)
@@ -3043,6 +3043,12 @@ WHERE  contribution_id = %1 ";
     ) {
       return;
     }
+    if (($params['prevContribution']->contribution_status_id == array_search('Partially paid', $contributionStatus))
+      && $params['contribution']->contribution_status_id == array_search('Completed', $contributionStatus)
+      && $context == 'changedStatus'
+    ) {
+      return;
+    }
     if ($context == 'changedAmount' || $context == 'changeFinancialType') {
       $itemAmount = $params['trxnParams']['total_amount'] = $params['total_amount'] - $params['prevContribution']->total_amount;
     }
@@ -3228,6 +3234,7 @@ WHERE  contribution_id = %1 ";
       'Pending' => array('Cancelled', 'Completed', 'Failed'),
       'In Progress' => array('Cancelled', 'Completed', 'Failed'),
       'Refunded' => array('Cancelled', 'Completed'),
+      'Partially paid' => array('Completed'),
     );
 
     if (!in_array($contributionStatuses[$fields['contribution_status_id']], $checkStatus[$contributionStatuses[$values['contribution_status_id']]])) {