Tax On Shipping Price Also

This commit is contained in:
devansh bawari 2020-12-14 13:33:25 +05:30
parent d01c57dae7
commit 3ac25cf746
1 changed files with 13 additions and 11 deletions

View File

@ -558,14 +558,6 @@ class Cart
$cart->grand_total = $cart->sub_total + $cart->tax_total - $cart->discount_amount;
$cart->base_grand_total = $cart->base_sub_total + $cart->base_tax_total - $cart->base_discount_amount;
if ($shipping = $cart->selected_shipping_rate) {
$cart->grand_total = (float)$cart->grand_total + $shipping->price - $shipping->discount_amount;
$cart->base_grand_total = (float)$cart->base_grand_total + $shipping->base_price - $shipping->base_discount_amount;
$cart->discount_amount += $shipping->discount_amount;
$cart->base_discount_amount += $shipping->base_discount_amount;
}
$cart = $this->finalizeCartTotals($cart);
$quantities = 0;
@ -577,7 +569,7 @@ class Cart
$cart->items_count = $cart->items->count();
$cart->items_qty = $quantities;
$cart->cart_currency_code = core()->getCurrentCurrencyCode();
$cart->save();
@ -700,8 +692,18 @@ class Cart
if ($haveTaxRate) {
$item->tax_percent = $rate->tax_rate;
$item->tax_amount = round(($item->total * $rate->tax_rate) / 100, 4);
$item->base_tax_amount = round(($item->base_total * $rate->tax_rate) / 100, 4);
/* getting shipping rate for tax calculation */
$shippingPrice = $shippingBasePrice = 0;
if ($shipping = $cart->selected_shipping_rate) {
$shippingPrice = $shipping->price - $shipping->discount_amount;
$shippingBasePrice = $shipping->base_price - $shipping->base_discount_amount;
}
/* now assigning shipping prices for tax calculation */
$item->tax_amount = round((($item->total + $shippingPrice) * $rate->tax_rate) / 100, 4);
$item->base_tax_amount = round((($item->base_total + $shippingBasePrice) * $rate->tax_rate) / 100, 4);
break;
}