Merge pull request #4360 from devansh-webkul/issue-4350
Fixed taxes not applied to Shipping Cost #4350
This commit is contained in:
commit
803075f303
|
|
@ -1290,6 +1290,7 @@ return [
|
|||
'description' => 'وصف',
|
||||
'rate' => 'معدل',
|
||||
'status' => 'الحالة',
|
||||
'calculate-tax' => 'احسب الضريبة',
|
||||
'type' => 'اكتب',
|
||||
'payment-methods' => 'طرق الدفع',
|
||||
'cash-on-delivery' => 'الدفع عند الاستلام',
|
||||
|
|
|
|||
|
|
@ -1297,6 +1297,7 @@ return [
|
|||
'description' => 'Beschreibung',
|
||||
'rate' => 'Rate',
|
||||
'status' => 'Status',
|
||||
'calculate-tax' => 'Steuern berechnen',
|
||||
'type' => 'Typ',
|
||||
'payment-methods' => 'Zahlungsmethoden',
|
||||
'cash-on-delivery' => 'Nachnahme',
|
||||
|
|
|
|||
|
|
@ -1295,6 +1295,7 @@ return [
|
|||
'description' => 'Description',
|
||||
'rate' => 'Rate',
|
||||
'status' => 'Status',
|
||||
'calculate-tax' => 'Calculate Tax',
|
||||
'type' => 'Type',
|
||||
'payment-methods' => 'Payment Methods',
|
||||
'cash-on-delivery' => 'Cash On Delivery',
|
||||
|
|
|
|||
|
|
@ -1279,6 +1279,7 @@ return [
|
|||
'description' => 'Descripción',
|
||||
'rate' => 'Tasa',
|
||||
'status' => 'Estado',
|
||||
'calculate-tax' => 'Calcular impuestos',
|
||||
'type' => 'Tipo',
|
||||
'payment-methods' => 'Métodos de pago',
|
||||
'cash-on-delivery' => 'Pago contraentrega',
|
||||
|
|
|
|||
|
|
@ -1285,6 +1285,7 @@ return [
|
|||
'description' => 'توضیحات',
|
||||
'rate' => 'نرخ',
|
||||
'status' => 'وضعیت',
|
||||
'calculate-tax' => 'محاسبه مالیات',
|
||||
'type' => 'نوع',
|
||||
'payment-methods' => 'روش های پرداخت',
|
||||
'cash-on-delivery' => 'پرداخت در محل',
|
||||
|
|
|
|||
|
|
@ -1290,6 +1290,7 @@ return [
|
|||
'description' => 'Descrizione',
|
||||
'rate' => 'Tasso',
|
||||
'status' => 'Stato',
|
||||
'calculate-tax' => 'Calcola le tasse',
|
||||
'type' => 'Tipo',
|
||||
'payment-methods' => 'Metodi di Pagamento',
|
||||
'cash-on-delivery' => 'Contrassegno',
|
||||
|
|
|
|||
|
|
@ -1286,6 +1286,7 @@ return [
|
|||
'description' => 'Omschrijving',
|
||||
'rate' => 'Tarief',
|
||||
'status' => 'Toestand',
|
||||
'calculate-tax' => 'Beregn skat',
|
||||
'type' => 'Type',
|
||||
'payment-methods' => 'Betaalmethodes',
|
||||
'cash-on-delivery' => 'Rembours',
|
||||
|
|
|
|||
|
|
@ -1287,6 +1287,7 @@ return [
|
|||
'description' => 'Opis',
|
||||
'rate' => 'Stawka',
|
||||
'status' => 'Status',
|
||||
'calculate-tax' => 'Oblicz podatek',
|
||||
'type' => 'Rodzaj',
|
||||
'payment-methods' => 'Metody płatności',
|
||||
'cash-on-delivery' => 'Za pobraniem',
|
||||
|
|
|
|||
|
|
@ -1286,6 +1286,7 @@ return [
|
|||
'description' => 'Descrição',
|
||||
'rate' => 'Taxa',
|
||||
'status' => 'Status',
|
||||
'calculate-tax' => 'Calcular o imposto',
|
||||
'type' => 'Tipo',
|
||||
'payment-methods' => 'Métodos de Pagamento',
|
||||
'cash-on-delivery' => 'Dinheiro na entrega',
|
||||
|
|
|
|||
|
|
@ -1274,6 +1274,7 @@ return [
|
|||
'description' => 'Açıklama',
|
||||
'rate' => 'Oran',
|
||||
'status' => 'Durum',
|
||||
'calculate-tax' => 'Vergiyi Hesapla',
|
||||
'type' => 'Tipi',
|
||||
'payment-methods' => 'Ödeme Türleri',
|
||||
'cash-on-delivery' => 'Kapıda Ödeme',
|
||||
|
|
|
|||
|
|
@ -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,20 @@ 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) {
|
||||
if ($shipping->is_calculate_tax) {
|
||||
$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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddIsTaxCalculationColumnToCartShippingRatesTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('cart_shipping_rates', function (Blueprint $table) {
|
||||
$table->boolean('is_calculate_tax')->default(true);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('cart_shipping_rates', function (Blueprint $table) {
|
||||
$table->dropColumn('is_calculate_tax');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -40,6 +40,7 @@ class FlatRate extends AbstractShipping
|
|||
$object->method = 'flatrate_flatrate';
|
||||
$object->method_title = $this->getConfigData('title');
|
||||
$object->method_description = $this->getConfigData('description');
|
||||
$object->is_calculate_tax = $this->getConfigData('is_calculate_tax');
|
||||
$object->price = 0;
|
||||
$object->base_price = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ class Free extends AbstractShipping
|
|||
$object->method = 'free_free';
|
||||
$object->method_title = $this->getConfigData('title');
|
||||
$object->method_description = $this->getConfigData('description');
|
||||
$object->is_calculate_tax = $this->getConfigData('is_calculate_tax');
|
||||
$object->price = 0;
|
||||
$object->base_price = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -2,21 +2,23 @@
|
|||
|
||||
return [
|
||||
'flatrate' => [
|
||||
'code' => 'flatrate',
|
||||
'title' => 'Flat Rate',
|
||||
'description' => 'Flat Rate Shipping',
|
||||
'active' => true,
|
||||
'default_rate' => '10',
|
||||
'type' => 'per_unit',
|
||||
'class' => 'Webkul\Shipping\Carriers\FlatRate',
|
||||
'code' => 'flatrate',
|
||||
'title' => 'Flat Rate',
|
||||
'description' => 'Flat Rate Shipping',
|
||||
'active' => true,
|
||||
'is_calculate_tax' => true,
|
||||
'default_rate' => '10',
|
||||
'type' => 'per_unit',
|
||||
'class' => 'Webkul\Shipping\Carriers\FlatRate',
|
||||
],
|
||||
|
||||
'free' => [
|
||||
'code' => 'free',
|
||||
'title' => 'Free Shipping',
|
||||
'description' => 'Free Shipping',
|
||||
'active' => true,
|
||||
'default_rate' => '0',
|
||||
'class' => 'Webkul\Shipping\Carriers\Free',
|
||||
'code' => 'free',
|
||||
'title' => 'Free Shipping',
|
||||
'description' => 'Free Shipping',
|
||||
'active' => true,
|
||||
'is_calculate_tax' => true,
|
||||
'default_rate' => '0',
|
||||
'class' => 'Webkul\Shipping\Carriers\Free',
|
||||
]
|
||||
];
|
||||
|
|
@ -35,6 +35,13 @@ return [
|
|||
'validation' => 'required',
|
||||
'channel_based' => false,
|
||||
'locale_based' => true,
|
||||
], [
|
||||
'name' => 'is_calculate_tax',
|
||||
'title' => 'admin::app.admin.system.calculate-tax',
|
||||
'type' => 'boolean',
|
||||
'validation' => 'required',
|
||||
'channel_based' => false,
|
||||
'locale_based' => false,
|
||||
]
|
||||
]
|
||||
], [
|
||||
|
|
@ -86,6 +93,13 @@ return [
|
|||
'validation' => 'required',
|
||||
'channel_based' => false,
|
||||
'locale_based' => true,
|
||||
], [
|
||||
'name' => 'is_calculate_tax',
|
||||
'title' => 'admin::app.admin.system.calculate-tax',
|
||||
'type' => 'boolean',
|
||||
'validation' => 'required',
|
||||
'channel_based' => false,
|
||||
'locale_based' => false,
|
||||
]
|
||||
]
|
||||
], [
|
||||
|
|
|
|||
Loading…
Reference in New Issue