Well, but it is still not fixing tax_excl in ps_orders Anyone?
--------------------
EDIT: Ok, to fix ps_orders total_paid_tax_excl and total_products we need to fix in getOrderTotal in Cart.php these lines - change _PS_PRICE_DISPLAY_PRECISION_ to 6 because this method is used in PaymentModule.php ValidateOrder class to compute prices but it is always passed with .00 .
Let's start.
In PaymentModule.php we need to change in ValidateOrder function this
$order->total_paid_tax_excl = (float)Tools::ps_round((float)$this->context->cart->getOrderTotal(false, Cart::BOTH, $order->product_list, $id_carrier), _PS_PRICE_COMPUTE_PRECISION_);
to this
$order->total_paid_tax_excl = (float)Tools::ps_round((float)$this->context->cart->getOrderTotal(false, Cart::BOTH, $order->product_list, $id_carrier), 6);
In Cart.php You need to change in getOrderTotal
$compute_precision = $configuration->get('_PS_PRICE_COMPUTE_PRECISION_');
to
$compute_precision = 6;
and change change this part of getOrderTotal to be like this.
switch ($ps_round_type) { case Order::ROUND_TOTAL: $products_total[$id_tax_rules_group.'_'.$id_address] += $price * (int)$product['cart_quantity']; break; case Order::ROUND_LINE: $product_price = $price * $product['cart_quantity']; $products_total[$id_tax_rules_group] += Tools::ps_round($product_price, $compute_precision); break; case Order::ROUND_ITEM: default: $product_price = $price; $products_total[$id_tax_rules_group] += Tools::ps_round($product_price, compute_precision) * (int)$product['cart_quantity']; break; }
Also make sure that you have return Tools::ps_round((float)$order_total, $compute_precision); at the of the getOrderTotal function.
Now let's check getProducts function from Cart.php and make sure that here You also have changed the switch function to this:
switch (Configuration::get('PS_ROUND_TYPE')) {
case Order::ROUND_TOTAL:
$row['total'] = $row['price_with_reduction_without_tax'] * (int)$row['cart_quantity'];
$row['total_wt'] = $row['price_with_reduction'] * (int)$row['cart_quantity'];
break;
case Order::ROUND_LINE:
$row['total'] = Tools::ps_round($row['price_with_reduction_without_tax'] * (int)$row['cart_quantity'], 6);
$row['total_wt'] = Tools::ps_round($row['price_with_reduction'] * (int)$row['cart_quantity'], _PS_PRICE_COMPUTE_PRECISION_);
break;
case Order::ROUND_ITEM:
default:
$row['total'] = Tools::ps_round($row['price_with_reduction_without_tax'], 6) * (int)$row['cart_quantity'];
$row['total_wt'] = Tools::ps_round($row['price_with_reduction'], _PS_PRICE_COMPUTE_PRECISION_) * (int)$row['cart_quantity'];
break;
}
To fix total_discounts_tax_excl in ps_orders you need to change in the same getOrderTotal in foreach ($cart_rules as $cart_rule) the very ending
// If the cart rule offers a reduction, the amount is prorated (with the products in the package) if ($cart_rule['obj']->reduction_percent > 0 || $cart_rule['obj']->reduction_amount > 0) { $order_total_discount += Tools::ps_round($cart_rule['obj']->getContextualValue($with_taxes, $virtual_context, CartRule::FILTER_ACTION_REDUCTION, $package, $use_cache), 6); } } $order_total_discount = min(Tools::ps_round($order_total_discount, 6), (float)$order_total_products) + (float)$order_shipping_discount;
If You want to fix total_shipping_cost_tax_excl in ps_orders then go public function getPackageShippingCost in Cart.php and change at the very end this
$shipping_cost = (float)Tools::ps_round((float)$shipping_cost, (Currency::getCurrencyInstance((int)$this->id_currency)->decimals * _PS_PRICE_DISPLAY_PRECISION_));
to this
$shipping_cost = (float)Tools::ps_round((float)$shipping_cost, (Currency::getCurrencyInstance((int)$this->id_currency)->decimals * 6));