Revert "dev/core#1603 remove places where taxAmount is rounded"
authorSeamus Lee <seamuslee001@gmail.com>
Mon, 22 Jun 2020 11:42:54 +0000 (21:42 +1000)
committerSeamus Lee <seamuslee001@gmail.com>
Mon, 22 Jun 2020 11:42:54 +0000 (21:42 +1000)
This reverts commit 777d61015ae35bb60a08f779d9aa8cb8dc9df708.

CRM/Contribute/BAO/Contribution.php
CRM/Price/BAO/PriceSet.php

index f1b2d3446a4c1784026b04572472b17ce849fb46..10501932192fd8a196c2cbcd2a3fcae5fa5ab200 100644 (file)
@@ -4204,7 +4204,7 @@ INNER JOIN civicrm_activity ON civicrm_activity_contact.activity_id = civicrm_ac
     ) {
       $taxRateParams = $taxRates[$params['financial_type_id']];
       $taxAmount = CRM_Contribute_BAO_Contribution_Utils::calculateTaxAmount(CRM_Utils_Array::value('total_amount', $params), $taxRateParams);
-      $params['tax_amount'] = $taxAmount['tax_amount'];
+      $params['tax_amount'] = round($taxAmount['tax_amount'], 2);
 
       // Get Line Item on update of contribution
       if (isset($params['id'])) {
@@ -4227,7 +4227,7 @@ INNER JOIN civicrm_activity ON civicrm_activity_contact.activity_id = civicrm_ac
         if (isset($value['financial_type_id']) && array_key_exists($value['financial_type_id'], $taxRates)) {
           $taxRate = $taxRates[$value['financial_type_id']];
           $taxAmount = CRM_Contribute_BAO_Contribution_Utils::calculateTaxAmount($value['line_total'], $taxRate);
-          $taxAmountArray[] = $taxAmount['tax_amount'];
+          $taxAmountArray[] = round($taxAmount['tax_amount'], 2);
         }
       }
       $params['tax_amount'] = array_sum($taxAmountArray);
@@ -4238,7 +4238,7 @@ INNER JOIN civicrm_activity ON civicrm_activity_contact.activity_id = civicrm_ac
       if (isset($params['financial_type_id']) && array_key_exists($params['financial_type_id'], $taxRates) && $isLineItem) {
         $taxRate = $taxRates[$params['financial_type_id']];
         $taxAmount = CRM_Contribute_BAO_Contribution_Utils::calculateTaxAmount($params['line_total'], $taxRate);
-        $params['tax_amount'] = $taxAmount['tax_amount'];
+        $params['tax_amount'] = round($taxAmount['tax_amount'], 2);
       }
     }
     return $params;
index bc089095945fa336dd27ea951283a8a2a6ed0648..2ed80ff8ebe8c62285c5729f15f6055ec85ccf02 100644 (file)
@@ -1485,10 +1485,10 @@ WHERE       ps.id = %1
   public static function setLineItem($field, $lineItem, $optionValueId, &$totalTax) {
     // Here we round - i.e. after multiplying by quantity
     if ($field['html_type'] == 'Text') {
-      $taxAmount = $field['options'][$optionValueId]['tax_amount'] * $lineItem[$optionValueId]['qty'];
+      $taxAmount = round($field['options'][$optionValueId]['tax_amount'] * $lineItem[$optionValueId]['qty'], 2);
     }
     else {
-      $taxAmount = $field['options'][$optionValueId]['tax_amount'];
+      $taxAmount = round($field['options'][$optionValueId]['tax_amount'], 2);
     }
     $taxRate = $field['options'][$optionValueId]['tax_rate'];
     $lineItem[$optionValueId]['tax_amount'] = $taxAmount;
@@ -1705,7 +1705,7 @@ WHERE     ct.id = cp.financial_type_id AND
           if (array_key_exists($params['financial_type_id'], $taxRates)) {
             $field['options'][key($field['options'])]['tax_rate'] = $taxRates[$params['financial_type_id']];
             $taxAmount = CRM_Contribute_BAO_Contribution_Utils::calculateTaxAmount($field['options'][$optionValueId]['amount'], $field['options'][$optionValueId]['tax_rate']);
-            $field['options'][$optionValueId]['tax_amount'] = $taxAmount['tax_amount'];
+            $field['options'][$optionValueId]['tax_amount'] = round($taxAmount['tax_amount'], 2);
           }
         }
         if (!empty($field['options'][$optionValueId]['tax_rate'])) {