diff --git a/install-dev/upgrade/php/migrate_orders.php b/install-dev/upgrade/php/migrate_orders.php index 6929bd07d..96160fa4b 100644 --- a/install-dev/upgrade/php/migrate_orders.php +++ b/install-dev/upgrade/php/migrate_orders.php @@ -95,7 +95,8 @@ function migrate_orders() $reduction_amount_tax_incl = (float)$products['reduction_amount']; // cart::getTaxesAverageUsed equivalent - $sum_total_products += $products['total_wt']; + $sum_total_products += $products['total_price']; + $sum_tax_amount += $products['total_wt'] - $products['total_price']; $order_details['reduction_amount_tax_incl'] = $reduction_amount_tax_incl; @@ -119,12 +120,11 @@ function migrate_orders() $average_tax_used = 1; if ($sum_total_products > 0) - $average_tax_used += ($sum_tax_amount / $sum_total_products) * 0.01; - + $average_tax_used += $sum_tax_amount / $sum_total_products; + $average_tax_used = round($average_tax_used, 4); $carrier_tax_rate = 1 + ((float)$order['carrier_tax_rate'] / 100); $total_discount_tax_excl = $order['total_discounts'] / $average_tax_used; - $order['total_discounts_tax_incl'] = (float)$order['total_discounts']; $order['total_discounts_tax_excl'] = (float)$total_discount_tax_excl; @@ -321,5 +321,4 @@ function mo_setProductPrices($row, $tax_calculation_method) $row['total_price'] = $row['product_quantity'] * $row['product_price']; return $row; -} - +} \ No newline at end of file