I'm having trouble with tax calculations for different products with group discounts. The store has taxable and non-taxable products as well as products that are discountable and non-discountable for group members. Thus I have four conditions to handle in ot_group_pricing.php: (1) taxable and discountable, (2) taxable and non-discountable, (3) non-taxable and discountable, and (4) non-taxable and non-discountable. I've modified ot_group_pricing.php to calculate the totals for each of the four conditions plus calculate total taxable and total non-taxable. The correct discount amount is calculated. A ratio used in tax calculations is defined as:
Code:
$ratio = $od_amount['total']/$order_total;
in line 96 of the unmodified ot_group_pricing zc157c code. Later, $ratio is used in the following code:
Code:
case 'Standard':
if ($od_amount['total'] >= $order_total) {
$ratio = 1;
}
$adjustedTax = $orderTotalTax * $ratio;
if ($order->info['tax'] == 0) return $od_amount;
$ratioTax = ($orderTotalTax != 0 ) ? $adjustedTax/$orderTotalTax : 0;
$tax_deduct = 0;
foreach ($taxGroups as $key=>$value) {
$od_amount['tax_groups'][$key] = $value * $ratioTax;
$tax_deduct += $od_amount['tax_groups'][$key];
}
$od_amount['tax'] = $tax_deduct;
break;
I think the ratio calculation needs to be modified, but I'm stuck. In the calculation of $ratio, should $order_total be replaced by the order discountable taxable total, the order discountable total, or something else? What exactly is $ratio supposed to represent? Any changes needed in the standard case block? The tax calculated is incorrect when mixed discountable and non-discountable products exist in the order.
Dave
zc157c, php7.3, only one tax - state sales tax
Bookmarks