Merge remote branch 'canonical/master' into merge-forward
[civicrm-core.git] / CRM / Contribute / BAO / Contribution / Utils.php
index b9c0864327e249e2ee759599fd755c107cbd8503..f4b958f98d16d21531112566da4de6fae9fe3dfe 100644 (file)
@@ -62,6 +62,8 @@ class CRM_Contribute_BAO_Contribution_Utils {
     $fieldTypes = NULL
   ) {
     CRM_Core_Payment_Form::mapParams($form->_bltID, $form->_params, $paymentParams, TRUE);
+    $isTest = ($form->_mode == 'test') ? 1 : 0;
+    $lineItems = $form->_lineItem;
 
     $contributionType = new CRM_Financial_DAO_FinancialType();
     if (isset($paymentParams['financial_type'])) {
@@ -111,7 +113,9 @@ class CRM_Contribute_BAO_Contribution_Utils {
         NULL,
         $contactID,
         $contributionType,
-        TRUE, TRUE, TRUE
+        TRUE, TRUE,
+        $isTest,
+        $lineItems
       );
 
       if ($contribution) {
@@ -230,7 +234,9 @@ class CRM_Contribute_BAO_Contribution_Utils {
           NULL,
           $contactID,
           $contributionType,
-          TRUE, TRUE, TRUE
+          TRUE, TRUE,
+          $isTest,
+          $lineItems
         );
 
         // restore cached values (part of fix for CRM-14354)
@@ -307,7 +313,9 @@ class CRM_Contribute_BAO_Contribution_Utils {
         $contribution = CRM_Contribute_Form_Contribution_Confirm::processContribution($form,
           $form->_params, $result,
           $contactID, $contributionType,
-          TRUE, $pending, TRUE
+          $pending, TRUE,
+          $isTest,
+          $lineItems
         );
       }
       $form->postProcessPremium($premiumParams, $contribution);
@@ -852,5 +860,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) * $amount;
+
+    return $taxAmount;
+  }
 }