Merge pull request #5214 from jitendrapurohit/CRM-15934changes
[civicrm-core.git] / CRM / Contribute / BAO / Contribution.php
index ab5a7b8d7ffff88987474b74c7084edca1de8cb9..76accef4136f25088da787ae89edc6c19076738e 100644 (file)
@@ -64,6 +64,15 @@ class CRM_Contribute_BAO_Contribution extends CRM_Contribute_DAO_Contribution {
    */
   public $_component = NULL;
 
+  /**
+   * Possibly obsolete variable.
+   *
+   * If you use it please explain why it is set in the create function here.
+   *
+   * @var string
+   */
+  public $trxn_result_code;
+
   /**
    * Class constructor.
    *
@@ -241,9 +250,13 @@ class CRM_Contribute_BAO_Contribution extends CRM_Contribute_DAO_Contribution {
   }
 
   /**
-   * @param array $params
+   * Calculate net_amount & fee_amount if they are not set.
    *
-   * @return mixed
+   * Net amount should be total - fee.
+   * This should only be called for new contributions.
+   *
+   * @param array $params
+   *   Params for a new contribution before they are saved.
    */
   public static function calculateMissingAmountParams(&$params) {
     if (!isset($params['fee_amount'])) {
@@ -1763,6 +1776,7 @@ LEFT JOIN  civicrm_contribution contribution ON ( componentPayment.contribution_
     $query = "
       SELECT    c.id                 as contribution_id,
                 c.contact_id         as contact_id,
+                c.contribution_recur_id,
                 mp.membership_id     as membership_id,
                 m.membership_type_id as membership_type_id,
                 pp.participant_id    as participant_id,
@@ -1798,6 +1812,9 @@ LEFT JOIN  civicrm_contribution contribution ON ( componentPayment.contribution_
       if ($dao->pledge_payment_id) {
         $pledgePayment[] = $dao->pledge_payment_id;
       }
+      if ($dao->contribution_recur_id) {
+        $componentDetails['contributionRecur'] = $dao->contribution_recur_id;
+      }
     }
 
     if ($pledgePayment) {
@@ -2830,6 +2847,7 @@ WHERE  contribution_id = %1 ";
 
         //Update contribution status
         $params['trxnParams']['status_id'] = $params['contribution']->contribution_status_id;
+        $params['trxnParams']['trxn_id'] = $params['contribution']->trxn_id;
         if (!empty($params['contribution_status_id']) &&
           $params['prevContribution']->contribution_status_id != $params['contribution']->contribution_status_id
         ) {