) {
$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'])) {
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);
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;
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;
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'])) {