From 527c452136ee3d1b5fd3ec60d02dececacae67f1 Mon Sep 17 00:00:00 2001 From: Jitendra Date: Wed, 24 Apr 2024 10:40:25 +0530 Subject: [PATCH 001/114] Inclusive and Exclusive tax --- packages/Webkul/Admin/src/Config/system.php | 229 ++++++++++++++++-- .../Admin/src/Http/Resources/CartResource.php | 2 +- .../Admin/src/Resources/lang/en/app.php | 59 ++++- .../views/configuration/field-type.blade.php | 4 + .../views/emails/orders/canceled.blade.php | 2 +- .../views/emails/orders/created.blade.php | 2 +- .../emails/orders/inventory-source.blade.php | 2 +- .../views/emails/orders/invoiced.blade.php | 2 +- .../views/emails/orders/refunded.blade.php | 2 +- .../views/emails/orders/shipped.blade.php | 2 +- .../views/sales/orders/view.blade.php | 2 +- packages/Webkul/Checkout/src/Cart.php | 175 +++++++++++-- ...d_incl_tax_columns_in_cart_items_table.php | 43 ++++ ...154_add_incl_tax_columns_in_cart_table.php | 45 ++++ ...x_columns_in_cart_shipping_rates_table.php | 44 ++++ .../Checkout/src/Models/CartShippingRate.php | 6 + .../Webkul/Product/src/Type/AbstractType.php | 98 +++----- packages/Webkul/Product/src/Type/Bundle.php | 37 ++- .../Webkul/Product/src/Type/Configurable.php | 20 +- .../Webkul/Product/src/Type/Downloadable.php | 29 ++- ...9_add_incl_tax_columns_in_orders_table.php | 43 ++++ ..._incl_tax_columns_in_order_items_table.php | 41 ++++ .../src/Transformers/OrderItemResource.php | 46 ++-- .../Sales/src/Transformers/OrderResource.php | 61 ++--- packages/Webkul/Shipping/src/Shipping.php | 3 +- .../src/Http/Resources/CartItemResource.php | 26 +- .../Shop/src/Http/Resources/CartResource.php | 58 ++--- .../Webkul/Shop/src/Resources/lang/en/app.php | 51 ++-- .../views/checkout/cart/index.blade.php | 39 ++- .../views/checkout/cart/mini-cart.blade.php | 126 ++++++---- .../views/checkout/cart/summary.blade.php | 189 ++++++++++++--- .../views/checkout/onepage/index.blade.php | 8 + .../views/checkout/onepage/summary.blade.php | 205 ++++++++++++---- .../views/emails/orders/canceled.blade.php | 2 +- .../views/emails/orders/created.blade.php | 2 +- .../views/emails/orders/invoiced.blade.php | 2 +- .../views/emails/orders/refunded.blade.php | 2 +- .../views/emails/orders/shipped.blade.php | 2 +- .../Resources/views/products/view.blade.php | 9 +- packages/Webkul/Tax/src/Facades/Tax.php | 18 ++ .../Tax/src/Providers/TaxServiceProvider.php | 14 ++ packages/Webkul/Tax/src/{Helpers => }/Tax.php | 76 +++--- .../default/build/assets/app-07ecee76.css | 1 + .../default/build/assets/app-54dcdf25.css | 1 - .../themes/shop/default/build/manifest.json | 2 +- 45 files changed, 1382 insertions(+), 450 deletions(-) create mode 100644 packages/Webkul/Checkout/src/Database/Migrations/2024_04_19_135405_add_incl_tax_columns_in_cart_items_table.php create mode 100644 packages/Webkul/Checkout/src/Database/Migrations/2024_04_23_133154_add_incl_tax_columns_in_cart_table.php create mode 100644 packages/Webkul/Checkout/src/Database/Migrations/2024_04_23_150945_add_incl_tax_columns_in_cart_shipping_rates_table.php create mode 100644 packages/Webkul/Sales/src/Database/Migrations/2024_04_19_102939_add_incl_tax_columns_in_orders_table.php create mode 100644 packages/Webkul/Sales/src/Database/Migrations/2024_04_19_144641_add_incl_tax_columns_in_order_items_table.php create mode 100755 packages/Webkul/Tax/src/Facades/Tax.php rename packages/Webkul/Tax/src/{Helpers => }/Tax.php (55%) create mode 100644 public/themes/shop/default/build/assets/app-07ecee76.css delete mode 100644 public/themes/shop/default/build/assets/app-54dcdf25.css diff --git a/packages/Webkul/Admin/src/Config/system.php b/packages/Webkul/Admin/src/Config/system.php index 2747b83c070..d8dc48339b9 100644 --- a/packages/Webkul/Admin/src/Config/system.php +++ b/packages/Webkul/Admin/src/Config/system.php @@ -1635,51 +1635,234 @@ ], ], ], [ - 'key' => 'taxes', - 'name' => 'admin::app.configuration.index.taxes.title', - 'info' => 'admin::app.configuration.index.taxes.title', - 'sort' => 6, - ], [ - 'key' => 'taxes.catalogue', - 'name' => 'admin::app.configuration.index.taxes.catalog.title', - 'info' => 'admin::app.configuration.index.taxes.catalog.title-info', + 'key' => 'sales.taxes', + 'name' => 'admin::app.configuration.index.sales.taxes.title', + 'info' => 'admin::app.configuration.index.sales.taxes.title-info', 'icon' => 'settings/tax.svg', - 'sort' => 1, + 'sort' => 6, ], [ - 'key' => 'taxes.catalogue.pricing', - 'name' => 'admin::app.configuration.index.taxes.catalog.pricing.title', - 'info' => 'admin::app.configuration.index.taxes.catalog.pricing.title-info', + 'key' => 'sales.taxes.categories', + 'name' => 'admin::app.configuration.index.sales.taxes.categories.title', + 'info' => 'admin::app.configuration.index.sales.taxes.categories.title-info', 'sort' => 1, 'fields' => [ [ - 'name' => 'tax_inclusive', - 'title' => 'admin::app.configuration.index.taxes.catalog.pricing.tax-inclusive', - 'type' => 'boolean', - 'default' => false, + 'name' => 'shipping', + 'title' => 'admin::app.configuration.index.sales.taxes.categories.shipping', + 'type' => 'select', + 'default' => 0, + 'options' => [ + [ + 'title' => 'admin::app.configuration.index.sales.taxes.categories.none', + 'value' => 0, + ], + ], + ], [ + 'name' => 'product', + 'title' => 'admin::app.configuration.index.sales.taxes.categories.product', + 'type' => 'select', + 'default' => 0, + 'options' => [ + [ + 'title' => 'admin::app.configuration.index.sales.taxes.categories.none', + 'value' => 0, + ], + ], ], ], ], [ - 'key' => 'taxes.catalogue.default_location_calculation', - 'name' => 'admin::app.configuration.index.taxes.catalog.default-location-calculation.title', - 'info' => 'admin::app.configuration.index.taxes.catalog.default-location-calculation.title-info', - 'sort' => 1, + 'key' => 'sales.taxes.calculation', + 'name' => 'admin::app.configuration.index.sales.taxes.calculation.title', + 'info' => 'admin::app.configuration.index.sales.taxes.calculation.title-info', + 'sort' => 2, + 'fields' => [ + [ + 'name' => 'based_on', + 'title' => 'admin::app.configuration.index.sales.taxes.calculation.based-on', + 'type' => 'select', + 'default' => 'shipping_address', + 'options' => [ + [ + 'title' => 'admin::app.configuration.index.sales.taxes.calculation.shipping-address', + 'value' => 'shipping_address', + ], [ + 'title' => 'admin::app.configuration.index.sales.taxes.calculation.billing-address', + 'value' => 'billing_address', + ], [ + 'title' => 'admin::app.configuration.index.sales.taxes.calculation.shipping-origin', + 'value' => 'shipping_origin', + ], + ], + ], [ + 'name' => 'product_prices', + 'title' => 'admin::app.configuration.index.sales.taxes.calculation.product-prices', + 'type' => 'select', + 'default' => 'excluding_tax', + 'options' => [ + [ + 'title' => 'admin::app.configuration.index.sales.taxes.calculation.excluding-tax', + 'value' => 'excluding_tax', + ], [ + 'title' => 'admin::app.configuration.index.sales.taxes.calculation.including-tax', + 'value' => 'including_tax', + ], + ], + ], [ + 'name' => 'shipping_prices', + 'title' => 'admin::app.configuration.index.sales.taxes.calculation.shipping-prices', + 'type' => 'select', + 'default' => 'excluding_tax', + 'options' => [ + [ + 'title' => 'admin::app.configuration.index.sales.taxes.calculation.excluding-tax', + 'value' => 'excluding_tax', + ], [ + 'title' => 'admin::app.configuration.index.sales.taxes.calculation.including-tax', + 'value' => 'including_tax', + ], + ], + ], + ], + ], [ + 'key' => 'sales.taxes.default_destination_calculation', + 'name' => 'admin::app.configuration.index.sales.taxes.default-destination-calculation.title', + 'info' => 'admin::app.configuration.index.sales.taxes.default-destination-calculation.title-info', + 'sort' => 3, 'fields' => [ [ 'name' => 'country', - 'title' => 'admin::app.configuration.index.taxes.catalog.default-location-calculation.default-country', + 'title' => 'admin::app.configuration.index.sales.taxes.default-destination-calculation.default-country', 'type' => 'country', 'default' => '', ], [ 'name' => 'state', - 'title' => 'admin::app.configuration.index.taxes.catalog.default-location-calculation.default-state', + 'title' => 'admin::app.configuration.index.sales.taxes.default-destination-calculation.default-state', 'type' => 'state', 'default' => '', ], [ 'name' => 'post_code', - 'title' => 'admin::app.configuration.index.taxes.catalog.default-location-calculation.default-post-code', + 'title' => 'admin::app.configuration.index.sales.taxes.default-destination-calculation.default-post-code', 'type' => 'text', 'default' => '', ], ], + ], [ + 'key' => 'sales.taxes.shopping_cart', + 'name' => 'admin::app.configuration.index.sales.taxes.shopping-cart.title', + 'info' => 'admin::app.configuration.index.sales.taxes.shopping-cart.title-info', + 'sort' => 4, + 'fields' => [ + [ + 'name' => 'display_prices', + 'title' => 'admin::app.configuration.index.sales.taxes.shopping-cart.display-prices', + 'type' => 'select', + 'default' => 'excluding_tax', + 'options' => [ + [ + 'title' => 'admin::app.configuration.index.sales.taxes.shopping-cart.excluding-tax', + 'value' => 'excluding_tax', + ], [ + 'title' => 'admin::app.configuration.index.sales.taxes.shopping-cart.including-tax', + 'value' => 'including_tax', + ], [ + 'title' => 'admin::app.configuration.index.sales.taxes.shopping-cart.both', + 'value' => 'both', + ], + ], + ], [ + 'name' => 'display_subtotal', + 'title' => 'admin::app.configuration.index.sales.taxes.shopping-cart.display-subtotal', + 'type' => 'select', + 'default' => 'excluding_tax', + 'options' => [ + [ + 'title' => 'admin::app.configuration.index.sales.taxes.shopping-cart.excluding-tax', + 'value' => 'excluding_tax', + ], [ + 'title' => 'admin::app.configuration.index.sales.taxes.shopping-cart.including-tax', + 'value' => 'including_tax', + ], [ + 'title' => 'admin::app.configuration.index.sales.taxes.shopping-cart.both', + 'value' => 'both', + ], + ], + ], [ + 'name' => 'display_shipping_amount', + 'title' => 'admin::app.configuration.index.sales.taxes.shopping-cart.display-shipping-amount', + 'type' => 'select', + 'default' => 'excluding_tax', + 'options' => [ + [ + 'title' => 'admin::app.configuration.index.sales.taxes.shopping-cart.excluding-tax', + 'value' => 'excluding_tax', + ], [ + 'title' => 'admin::app.configuration.index.sales.taxes.shopping-cart.including-tax', + 'value' => 'including_tax', + ], [ + 'title' => 'admin::app.configuration.index.sales.taxes.shopping-cart.both', + 'value' => 'both', + ], + ], + ], + ], + ], [ + 'key' => 'sales.taxes.sales', + 'name' => 'admin::app.configuration.index.sales.taxes.sales.title', + 'info' => 'admin::app.configuration.index.sales.taxes.sales.title-info', + 'sort' => 4, + 'fields' => [ + [ + 'name' => 'display_prices', + 'title' => 'admin::app.configuration.index.sales.taxes.sales.display-prices', + 'type' => 'select', + 'default' => 'excluding_tax', + 'options' => [ + [ + 'title' => 'admin::app.configuration.index.sales.taxes.sales.excluding-tax', + 'value' => 'excluding_tax', + ], [ + 'title' => 'admin::app.configuration.index.sales.taxes.sales.including-tax', + 'value' => 'including_tax', + ], [ + 'title' => 'admin::app.configuration.index.sales.taxes.sales.both', + 'value' => 'both', + ], + ], + ], [ + 'name' => 'display_subtotal', + 'title' => 'admin::app.configuration.index.sales.taxes.sales.display-subtotal', + 'type' => 'select', + 'default' => 'excluding_tax', + 'options' => [ + [ + 'title' => 'admin::app.configuration.index.sales.taxes.sales.excluding-tax', + 'value' => 'excluding_tax', + ], [ + 'title' => 'admin::app.configuration.index.sales.taxes.sales.including-tax', + 'value' => 'including_tax', + ], [ + 'title' => 'admin::app.configuration.index.sales.taxes.sales.both', + 'value' => 'both', + ], + ], + ], [ + 'name' => 'display_shipping_amount', + 'title' => 'admin::app.configuration.index.sales.taxes.sales.display-shipping-amount', + 'type' => 'select', + 'default' => 'excluding_tax', + 'options' => [ + [ + 'title' => 'admin::app.configuration.index.sales.taxes.sales.excluding-tax', + 'value' => 'excluding_tax', + ], [ + 'title' => 'admin::app.configuration.index.sales.taxes.sales.including-tax', + 'value' => 'including_tax', + ], [ + 'title' => 'admin::app.configuration.index.sales.taxes.sales.both', + 'value' => 'both', + ], + ], + ], + ], ], ]; diff --git a/packages/Webkul/Admin/src/Http/Resources/CartResource.php b/packages/Webkul/Admin/src/Http/Resources/CartResource.php index 9d58747d4cf..41f8b93b39a 100644 --- a/packages/Webkul/Admin/src/Http/Resources/CartResource.php +++ b/packages/Webkul/Admin/src/Http/Resources/CartResource.php @@ -3,7 +3,7 @@ namespace Webkul\Admin\Http\Resources; use Illuminate\Http\Resources\Json\JsonResource; -use Webkul\Tax\Helpers\Tax; +use Webkul\Tax\Facades\Tax; class CartResource extends JsonResource { diff --git a/packages/Webkul/Admin/src/Resources/lang/en/app.php b/packages/Webkul/Admin/src/Resources/lang/en/app.php index 94b224c9bab..5f2d9ba9363 100755 --- a/packages/Webkul/Admin/src/Resources/lang/en/app.php +++ b/packages/Webkul/Admin/src/Resources/lang/en/app.php @@ -3750,27 +3750,60 @@ 'title-info' => 'Automated notifications or communications sent to customers to remind them of upcoming or overdue payments for invoices.', ], ], - ], - 'taxes' => [ - 'title' => 'Taxes', + 'taxes' => [ + 'title' => 'Taxes', + 'title-info' => 'Taxes are mandatory fees imposed by governments on goods, services, or transactions, collected by sellers and remitted to the authorities.', - 'catalog' => [ - 'title' => 'Catalog', - 'title-info' => 'Set pricing and default location calculations', + 'categories' => [ + 'title' => 'Tax Categories', + 'title-info' => 'Tax categories are classifications for different types of taxes, such as sales tax, value-added tax, or excise tax, used to categorize and apply tax rates to products or services.', + 'product' => 'Product Default Tax Category', + 'shipping' => 'Shipping Tax Category', + 'none' => 'None', + ], - 'pricing' => [ - 'title' => 'Pricing', - 'title-info' => 'Details about the cost of goods or services, including base price, discounts, taxes, and additional charges.information', - 'tax-inclusive' => 'Tax inclusive', + 'calculation' => [ + 'title' => 'Calculation Settings', + 'title-info' => 'Details about the cost of goods or services, including base price, discounts, taxes, and additional charges.information', + 'based-on' => 'Calculation Based On', + 'shipping-address' => 'Shipping Address', + 'billing-address' => 'Billing Address', + 'shipping-origin' => 'Shipping Origin', + 'product-prices' => 'Product Prices', + 'shipping-prices' => 'Shipping Prices', + 'excluding-tax' => 'Excluding Tax', + 'including-tax' => 'Including Tax', ], - 'default-location-calculation' => [ + 'default-destination-calculation' => [ 'default-country' => 'Default Country', 'default-post-code' => 'Default Post Code', 'default-state' => 'Default State', - 'title' => 'Default Location Calculation', - 'title-info' => 'Automated determination of a standard or initial location based on predefined factors or settings.', + 'title' => 'Default Destination Calculation', + 'title-info' => 'Automated determination of a standard or initial destination based on predefined factors or settings.', + ], + + 'shopping-cart' => [ + 'title' => 'Shopping Cart Display Settings', + 'title-info' => 'Set the display of taxes in the shopping cart', + 'display-prices' => 'Display Prices', + 'display-subtotal' => 'Display Subtotal', + 'display-shipping-amount' => 'Display Shipping Amount', + 'excluding-tax' => 'Excluding Tax', + 'including-tax' => 'Including Tax', + 'both' => 'Excluding and Including Both', + ], + + 'sales' => [ + 'title' => 'Orders, Invoices, Refunds Display Settings', + 'title-info' => 'Set the display of taxes in the orders, invoices, and refunds', + 'display-prices' => 'Display Prices', + 'display-subtotal' => 'Display Subtotal', + 'display-shipping-amount' => 'Display Shipping Amount', + 'excluding-tax' => 'Excluding Tax', + 'including-tax' => 'Including Tax', + 'both' => 'Excluding and Including Both', ], ], ], diff --git a/packages/Webkul/Admin/src/Resources/views/configuration/field-type.blade.php b/packages/Webkul/Admin/src/Resources/views/configuration/field-type.blade.php index 7665b88c2c4..f936b3883a4 100755 --- a/packages/Webkul/Admin/src/Resources/views/configuration/field-type.blade.php +++ b/packages/Webkul/Admin/src/Resources/views/configuration/field-type.blade.php @@ -347,6 +347,10 @@ class="cursor-pointer" @lang('admin::app.configuration.index.select-state') + +