--fixed net amount field during update of contribution amount
[civicrm-core.git] / CRM / Contribute / BAO / Contribution.php
index 04c72bc5e3dfcc23d7943045514e5fc9eddae646..ffb02e8458bd00c19d4fc64278e14754ca7775ad 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.6                                                |
+ | CiviCRM version 4.7                                                |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2015                                |
  +--------------------------------------------------------------------+
@@ -2360,7 +2360,11 @@ WHERE  contribution_id = %1 ";
       //for tasks 'Change Participant Status' and 'Batch Update Participants Via Profile' case
       //and cases involving status updation through ipn
       // whatever that means!
-      $values['totalAmount'] = $input['amount'];
+      // total_amount appears to be the preferred input param & it is unclear why we support amount here
+      // perhaps we should throw an e-notice if amount is set & force total_amount?
+      if (!empty($input['amount'])) {
+        $values['totalAmount'] = $input['amount'];
+      }
 
       if ($values['event']['is_email_confirm']) {
         $values['is_email_receipt'] = 1;
@@ -3134,7 +3138,7 @@ WHERE  contribution_id = %1 ";
       return;
     }
     if ($context == 'changedAmount' || $context == 'changeFinancialType') {
-      $itemAmount = $params['trxnParams']['total_amount'] = $params['total_amount'] - $params['prevContribution']->total_amount;
+      $itemAmount = $params['trxnParams']['total_amount'] = $params['trxnParams']['net_amount'] = $params['total_amount'] - $params['prevContribution']->total_amount;
     }
     if ($context == 'changedStatus') {
       //get all the statuses
@@ -4044,6 +4048,7 @@ WHERE con.id = {$contributionId}
       'payment_instrument_id',
       'is_test',
       'campaign_id',
+      'receive_date',
     );
 
     $contributionParams = array_merge(array(