Merge remote-tracking branch 'upstream/4.5' into 4.5-master-2014-10-14-11-24-52
[civicrm-core.git] / CRM / Contribute / BAO / Contribution / Utils.php
index fdb830594a177d278b919717918eadc4e3e96c6d..849c61705c67f0e0e5129c9b2987d3f17294763f 100644 (file)
@@ -330,7 +330,9 @@ class CRM_Contribute_BAO_Contribution_Utils {
         );
       }
       $form->postProcessPremium($premiumParams, $contribution);
-
+      if (is_array($result) && !empty($result['trxn_id'])) {
+        $contribution->trxn_id = $result['trxn_id'];
+      }
       $membershipResult[1] = $contribution;
     }
 
@@ -871,5 +873,24 @@ LIMIT 1
     }
     return $_cache[$contactID];
   }
+
+  /**
+   * Calculate the tax amount based on given tax rate.
+   *
+   * @param float $amount amount of field.
+   * @param float $taxRate tax rate of selected financial account for field.
+   *
+   * @return array array of tax amount
+   *
+   * @access public
+   * @static
+   *
+   */
+  public static function calculateTaxAmount($amount, $taxRate) {
+    $taxAmount = array();
+    $taxAmount['tax_amount'] = ($taxRate/100) * CRM_Utils_Rule::cleanMoney($amount);
+
+    return $taxAmount;
+  }
 }