-
-@stop
-
-
-
diff --git a/packages/Webkul/Admin/src/Resources/views/sales/address.blade.php b/packages/Webkul/Admin/src/Resources/views/sales/address.blade.php
new file mode 100644
index 000000000..845fd9e6e
--- /dev/null
+++ b/packages/Webkul/Admin/src/Resources/views/sales/address.blade.php
@@ -0,0 +1,4 @@
+{{ $address->name }}
+{{ $address->address1 }}, {{ $address->address2 ? $address->address2 . ',' : '' }} {{ $address->state }}
+{{ country()->name($address->country) }} {{ $address->postcode }}
+{{ __('shop::app.checkout.onepage.contact') }} : {{ $address->phone }}
\ No newline at end of file
diff --git a/packages/Webkul/Admin/src/Resources/views/sales/invoices/create.blade.php b/packages/Webkul/Admin/src/Resources/views/sales/invoices/create.blade.php
new file mode 100644
index 000000000..7c68bba07
--- /dev/null
+++ b/packages/Webkul/Admin/src/Resources/views/sales/invoices/create.blade.php
@@ -0,0 +1,250 @@
+@extends('admin::layouts.master')
+
+@section('page_title')
+ {{ __('admin::app.sales.invoices.add-title') }}
+@stop
+
+@section('content-wrapper')
+
+@stop
\ No newline at end of file
diff --git a/packages/Webkul/Admin/src/Resources/views/sales/invoices/view.blade.php b/packages/Webkul/Admin/src/Resources/views/sales/invoices/view.blade.php
new file mode 100644
index 000000000..c1e9d5abe
--- /dev/null
+++ b/packages/Webkul/Admin/src/Resources/views/sales/invoices/view.blade.php
@@ -0,0 +1,266 @@
+@extends('admin::layouts.master')
+
+@section('page_title')
+ {{ __('admin::app.sales.invoices.view-title', ['invoice_id' => $invoice->id]) }}
+@stop
+
+@section('content-wrapper')
+ order; ?>
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ __('admin::app.sales.orders.order-info') }}
+
+
+
+
+
+
+
+ {{ __('admin::app.sales.orders.order-date') }}
+
+
+
+ {{ $order->created_at }}
+
+
+
+
+
+ {{ __('admin::app.sales.orders.order-status') }}
+
+
+
+ {{ $order->status_label }}
+
+
+
+
+
+ {{ __('admin::app.sales.orders.channel') }}
+
+
+
+ {{ $order->channel_name }}
+
+
+
+
+
+
+
+ {{ __('admin::app.sales.orders.account-info') }}
+
+
+
+
+
+ {{ __('admin::app.sales.orders.customer-name') }}
+
+
+
+ {{ $invoice->address->name }}
+
+
+
+
+
+ {{ __('admin::app.sales.orders.email') }}
+
+
+
+ {{ $invoice->address->email }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ __('admin::app.sales.orders.billing-address') }}
+
+
+
+
+ @include ('admin::sales.address', ['address' => $order->billing_address])
+
+
+
+
+ @if($order->shipping_address)
+
+
+ {{ __('admin::app.sales.orders.shipping-address') }}
+
+
+
+
+ @include ('admin::sales.address', ['address' => $order->shipping_address])
+
+
+
+ @endif
+
+
+
+
+
+
+
+
+
+ {{ __('admin::app.sales.orders.payment-info') }}
+
+
+
+
+
+ {{ __('admin::app.sales.orders.payment-method') }}
+
+
+
+ {{ core()->getConfigData('paymentmethods.' . $order->payment->method . '.title') }}
+
+
+
+
+
+ {{ __('admin::app.sales.orders.currency') }}
+
+
+
+ {{ $order->order_currency_code }}
+
+
+
+
+
+
+
+ {{ __('admin::app.sales.orders.shipping-info') }}
+
+
+
+
+
+ {{ __('admin::app.sales.orders.shipping-method') }}
+
+
+
+ {{ $order->shipping_title }}
+
+
+
+
+
+ {{ __('admin::app.sales.orders.shipping-price') }}
+
+
+
+ {{ core()->formatBasePrice($order->base_shipping_amount) }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ | {{ __('admin::app.sales.orders.SKU') }} |
+ {{ __('admin::app.sales.orders.product-name') }} |
+ {{ __('admin::app.sales.orders.price') }} |
+ {{ __('admin::app.sales.orders.qty') }} |
+ {{ __('admin::app.sales.orders.subtotal') }} |
+ {{ __('admin::app.sales.orders.tax-amount') }} |
+ {{ __('admin::app.sales.orders.grand-total') }} |
+
+
+
+
+
+ @foreach ($invoice->items as $item)
+
+ | {{ $item->child ? $item->child->sku : $item->sku }} |
+ {{ $item->name }} |
+ {{ core()->formatBasePrice($item->base_price) }} |
+ {{ $item->qty }} |
+ {{ core()->formatBasePrice($item->base_total) }} |
+ {{ core()->formatBasePrice($item->base_tax_amount) }} |
+ {{ core()->formatBasePrice($item->base_total + $item->base_tax_amount) }} |
+
+ @endforeach
+
+
+
+
+
+
+
+ | {{ __('admin::app.sales.orders.subtotal') }} |
+ - |
+ {{ core()->formatBasePrice($invoice->base_sub_total) }} |
+
+
+
+ | {{ __('admin::app.sales.orders.shipping-handling') }} |
+ - |
+ {{ core()->formatBasePrice($invoice->base_shipping_amount) }} |
+
+
+
+ | {{ __('admin::app.sales.orders.tax') }} |
+ - |
+ {{ core()->formatBasePrice($invoice->base_tax_amount) }} |
+
+
+
+ | {{ __('admin::app.sales.orders.grand-total') }} |
+ - |
+ {{ core()->formatBasePrice($invoice->base_grand_total) }} |
+
+
+
+
+
+
+
+
+
+
+@stop
\ No newline at end of file
diff --git a/packages/Webkul/Admin/src/Resources/views/sales/orders/index.blade.php b/packages/Webkul/Admin/src/Resources/views/sales/orders/index.blade.php
new file mode 100644
index 000000000..77b45387e
--- /dev/null
+++ b/packages/Webkul/Admin/src/Resources/views/sales/orders/index.blade.php
@@ -0,0 +1,22 @@
+@extends('admin::layouts.master')
+
+@section('page_title')
+ {{ __('admin::app.sales.orders.title') }}
+@stop
+
+@section('content-wrapper')
+
+@stop
\ No newline at end of file
diff --git a/packages/Webkul/Admin/src/Resources/views/sales/orders/view.blade.php b/packages/Webkul/Admin/src/Resources/views/sales/orders/view.blade.php
new file mode 100644
index 000000000..5ae99d096
--- /dev/null
+++ b/packages/Webkul/Admin/src/Resources/views/sales/orders/view.blade.php
@@ -0,0 +1,365 @@
+@extends('admin::layouts.master')
+
+@section('page_title')
+ {{ __('admin::app.sales.orders.view-title', ['order_id' => $order->id]) }}
+@stop
+
+@section('content-wrapper')
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ __('admin::app.sales.orders.order-info') }}
+
+
+
+
+
+ {{ __('admin::app.sales.orders.order-date') }}
+
+
+
+ {{ $order->created_at }}
+
+
+
+
+
+ {{ __('admin::app.sales.orders.order-status') }}
+
+
+
+ {{ $order->status_label }}
+
+
+
+
+
+ {{ __('admin::app.sales.orders.channel') }}
+
+
+
+ {{ $order->channel_name }}
+
+
+
+
+
+
+
+ {{ __('admin::app.sales.orders.account-info') }}
+
+
+
+
+
+ {{ __('admin::app.sales.orders.customer-name') }}
+
+
+
+ {{ $order->customer_full_name }}
+
+
+
+
+
+ {{ __('admin::app.sales.orders.email') }}
+
+
+
+ {{ $order->customer_email }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ __('admin::app.sales.orders.billing-address') }}
+
+
+
+
+ @include ('admin::sales.address', ['address' => $order->billing_address])
+
+
+
+
+ @if($order->shipping_address)
+
+
+ {{ __('admin::app.sales.orders.shipping-address') }}
+
+
+
+
+ @include ('admin::sales.address', ['address' => $order->shipping_address])
+
+
+
+ @endif
+
+
+
+
+
+
+
+
+
+ {{ __('admin::app.sales.orders.payment-info') }}
+
+
+
+
+
+ {{ __('admin::app.sales.orders.payment-method') }}
+
+
+
+ {{ core()->getConfigData('paymentmethods.' . $order->payment->method . '.title') }}
+
+
+
+
+
+ {{ __('admin::app.sales.orders.currency') }}
+
+
+
+ {{ $order->order_currency_code }}
+
+
+
+
+
+
+
+ {{ __('admin::app.sales.orders.shipping-info') }}
+
+
+
+
+
+ {{ __('admin::app.sales.orders.shipping-method') }}
+
+
+
+ {{ $order->shipping_title }}
+
+
+
+
+
+ {{ __('admin::app.sales.orders.shipping-price') }}
+
+
+
+ {{ core()->formatBasePrice($order->base_shipping_amount) }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ | {{ __('admin::app.sales.orders.SKU') }} |
+ {{ __('admin::app.sales.orders.product-name') }} |
+ {{ __('admin::app.sales.orders.price') }} |
+ {{ __('admin::app.sales.orders.qty') }} |
+ {{ __('admin::app.sales.orders.item-status') }} |
+ {{ __('admin::app.sales.orders.subtotal') }} |
+ {{ __('admin::app.sales.orders.tax-percent') }} |
+ {{ __('admin::app.sales.orders.tax-amount') }} |
+ {{ __('admin::app.sales.orders.grand-total') }} |
+
+
+
+
+
+ @foreach ($order->items as $item)
+
+ |
+ {{ $item->type == 'configurable' ? $item->child->sku : $item->sku }}
+ |
+ {{ $item->name }} |
+ {{ core()->formatBasePrice($item->base_price) }} |
+ {{ $item->qty_ordered }} |
+ Packed (2) |
+ {{ core()->formatBasePrice($item->base_total) }} |
+ {{ $item->tax_percent }}% |
+ {{ core()->formatBasePrice($item->base_tax_amount) }} |
+ {{ core()->formatBasePrice($item->base_total + $item->base_tax_amount) }} |
+
+ @endforeach
+
+
+
+
+
+ | {{ __('admin::app.sales.orders.subtotal') }} |
+ - |
+ {{ core()->formatBasePrice($order->base_sub_total) }} |
+
+
+
+ | {{ __('admin::app.sales.orders.shipping-handling') }} |
+ - |
+ {{ core()->formatBasePrice($order->base_shipping_amount) }} |
+
+
+
+ | {{ __('admin::app.sales.orders.tax') }} |
+ - |
+ {{ core()->formatBasePrice($order->base_tax_amount) }} |
+
+
+
+ | {{ __('admin::app.sales.orders.grand-total') }} |
+ - |
+ {{ core()->formatBasePrice($order->base_grand_total) }} |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ | {{ __('admin::app.sales.invoices.id') }} |
+ {{ __('admin::app.sales.invoices.date') }} |
+ {{ __('admin::app.sales.invoices.order-id') }} |
+ {{ __('admin::app.sales.invoices.customer-name') }} |
+ {{ __('admin::app.sales.invoices.status') }} |
+ {{ __('admin::app.sales.invoices.amount') }} |
+ {{ __('admin::app.sales.invoices.action') }} |
+
+
+
+
+
+ @foreach ($order->invoices as $invoice)
+
+ | #{{ $invoice->id }} |
+ {{ $invoice->created_at }} |
+ #{{ $invoice->order->id }} |
+ {{ $invoice->address->name }} |
+ {{ $invoice->status_label }} |
+ {{ core()->formatBasePrice($invoice->base_grand_total) }} |
+
+
+
+
+ |
+
+ @endforeach
+
+ @if (!$order->invoices->count())
+
+ | {{ __('admin::app.common.no-result-found') }} |
+
+ @endif
+
+
+
+
+
+
+
+
+
+
+
+ | {{ __('admin::app.sales.shipments.id') }} |
+ {{ __('admin::app.sales.shipments.date') }} |
+ {{ __('admin::app.sales.shipments.order-id') }} |
+ {{ __('admin::app.sales.shipments.order-date') }} |
+ {{ __('admin::app.sales.shipments.customer-name') }} |
+ {{ __('admin::app.sales.shipments.total-qty') }} |
+ {{ __('admin::app.sales.shipments.action') }} |
+
+
+
+
+
+ @foreach ($order->shipments as $shipment)
+
+ | #{{ $shipment->id }} |
+ {{ $shipment->created_at }} |
+ #{{ $shipment->order->id }} |
+ {{ $shipment->order->created_at }} |
+ {{ $shipment->address->name }} |
+ {{ $shipment->total_qty }} |
+
+
+
+
+ |
+
+ @endforeach
+
+ @if (!$order->shipments->count())
+
+ | {{ __('admin::app.common.no-result-found') }} |
+
+ @endif
+
+
+
+
+
+
+
+
+@stop
\ No newline at end of file
diff --git a/packages/Webkul/Admin/src/Resources/views/sales/shipments/create.blade.php b/packages/Webkul/Admin/src/Resources/views/sales/shipments/create.blade.php
new file mode 100644
index 000000000..481384e26
--- /dev/null
+++ b/packages/Webkul/Admin/src/Resources/views/sales/shipments/create.blade.php
@@ -0,0 +1,266 @@
+@extends('admin::layouts.master')
+
+@section('page_title')
+ {{ __('admin::app.sales.shipments.add-title') }}
+@stop
+
+@section('content-wrapper')
+
+@stop
\ No newline at end of file
diff --git a/packages/Webkul/Admin/src/Resources/views/sales/shipments/view.blade.php b/packages/Webkul/Admin/src/Resources/views/sales/shipments/view.blade.php
new file mode 100644
index 000000000..fd8c5ae50
--- /dev/null
+++ b/packages/Webkul/Admin/src/Resources/views/sales/shipments/view.blade.php
@@ -0,0 +1,251 @@
+@extends('admin::layouts.master')
+
+@section('page_title')
+ {{ __('admin::app.sales.shipments.view-title', ['shipment_id' => $shipment->id]) }}
+@stop
+
+@section('content-wrapper')
+ order; ?>
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ __('admin::app.sales.orders.order-info') }}
+
+
+
+
+
+
+
+ {{ __('admin::app.sales.orders.order-date') }}
+
+
+
+ {{ $order->created_at }}
+
+
+
+
+
+ {{ __('admin::app.sales.orders.order-status') }}
+
+
+
+ {{ $order->status_label }}
+
+
+
+
+
+ {{ __('admin::app.sales.orders.channel') }}
+
+
+
+ {{ $order->channel_name }}
+
+
+
+
+
+
+
+ {{ __('admin::app.sales.orders.account-info') }}
+
+
+
+
+
+ {{ __('admin::app.sales.orders.customer-name') }}
+
+
+
+ {{ $shipment->address->name }}
+
+
+
+
+
+ {{ __('admin::app.sales.orders.email') }}
+
+
+
+ {{ $shipment->address->email }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ __('admin::app.sales.orders.billing-address') }}
+
+
+
+
+ @include ('admin::sales.address', ['address' => $order->billing_address])
+
+
+
+
+ @if($order->shipping_address)
+
+
+ {{ __('admin::app.sales.orders.shipping-address') }}
+
+
+
+
+ @include ('admin::sales.address', ['address' => $order->shipping_address])
+
+
+
+ @endif
+
+
+
+
+
+
+
+
+
+ {{ __('admin::app.sales.orders.payment-info') }}
+
+
+
+
+
+ {{ __('admin::app.sales.orders.payment-method') }}
+
+
+
+ {{ core()->getConfigData('paymentmethods.' . $order->payment->method . '.title') }}
+
+
+
+
+
+ {{ __('admin::app.sales.orders.currency') }}
+
+
+
+ {{ $order->order_currency_code }}
+
+
+
+
+
+
+
+ {{ __('admin::app.sales.orders.shipping-info') }}
+
+
+
+
+
+ {{ __('admin::app.sales.orders.shipping-method') }}
+
+
+
+ {{ $order->shipping_title }}
+
+
+
+
+
+ {{ __('admin::app.sales.orders.shipping-price') }}
+
+
+
+ {{ core()->formatBasePrice($order->base_shipping_amount) }}
+
+
+
+
+
+ {{ __('admin::app.sales.shipments.carrier-title') }}
+
+
+
+ {{ $shipment->carrier_title }}
+
+
+
+
+
+ {{ __('admin::app.sales.shipments.tracking-number') }}
+
+
+
+ {{ $shipment->track_number }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ | {{ __('admin::app.sales.orders.SKU') }} |
+ {{ __('admin::app.sales.orders.product-name') }} |
+ {{ __('admin::app.sales.orders.qty') }} |
+
+
+
+
+
+ @foreach ($shipment->items as $item)
+
+ | {{ $item->sku }} |
+ {{ $item->name }} |
+ {{ $item->qty }} |
+
+ @endforeach
+
+
+
+
+
+
+
+
+
+
+
+@stop
\ No newline at end of file
diff --git a/packages/Webkul/Checkout/src/Cart.php b/packages/Webkul/Checkout/src/Cart.php
index 1a60ef414..f6a95a0e1 100644
--- a/packages/Webkul/Checkout/src/Cart.php
+++ b/packages/Webkul/Checkout/src/Cart.php
@@ -633,17 +633,22 @@ class Cart {
$cart->grand_total = 0;
$cart->base_grand_total = 0;
+
$cart->sub_total = 0;
$cart->base_sub_total = 0;
- $cart->sub_total_with_discount = 0;
- $cart->base_sub_total_with_discount = 0;
+
+ $cart->tax_total = 0;
+ $cart->base_tax_total = 0;
foreach ($cart->items()->get() as $item) {
$cart->grand_total = (float) $cart->grand_total + $item->total;
$cart->base_grand_total = (float) $cart->base_grand_total + $item->base_total;
- $cart->sub_total = (float) $cart->sub_total + $item->price * $item->quantity;
- $cart->base_sub_total = (float) $cart->base_sub_total + $item->base_price * $item->quantity;
+ $cart->sub_total = (float) $cart->sub_total + $item->total;
+ $cart->base_sub_total = (float) $cart->base_sub_total + $item->base_total;
+
+ $cart->tax_total = (float) $cart->tax_total + $item->tax_amount;
+ $cart->base_tax_total = (float) $cart->base_tax_total + $item->base_tax_amount;
}
if($shipping = $cart->selected_shipping_rate) {
@@ -882,6 +887,7 @@ class Cart {
'customer' => auth()->guard('customer')->check() ? auth()->guard('customer')->user : null,
'shipping_method' => $data['selected_shipping_rate']['method'],
+ 'shipping_title' => $data['selected_shipping_rate']['carrier_title'] . ' - ' . $data['selected_shipping_rate']['method_title'],
'shipping_description' => $data['selected_shipping_rate']['method_description'],
'shipping_amount' => $data['selected_shipping_rate']['price'],
'base_shipping_amount' => $data['selected_shipping_rate']['base_price'],
@@ -895,10 +901,14 @@ class Cart {
'base_grand_total' => $data['base_grand_total'],
'sub_total' => $data['sub_total'],
'base_sub_total' => $data['base_sub_total'],
+ 'tax_amount' => $data['tax_total'],
+ 'base_tax_amount' => $data['base_tax_total'],
'shipping_address' => array_except($data['shipping_address'], ['id', 'cart_id']),
'billing_address' => array_except($data['billing_address'], ['id', 'cart_id']),
'payment' => array_except($data['payment'], ['id', 'cart_id']),
+
+ 'channel' => core()->getCurrentChannel(),
];
foreach($data['items'] as $item) {
@@ -927,6 +937,9 @@ class Cart {
'base_price' => $data['base_price'],
'total' => $data['total'],
'base_total' => $data['base_total'],
+ 'tax_percent' => $data['tax_percent'],
+ 'tax_amount' => $data['tax_amount'],
+ 'base_tax_amount' => $data['base_tax_amount'],
'additional' => $data['additional'],
];
diff --git a/packages/Webkul/Checkout/src/Database/Migrations/2018_09_05_150444_create_cart_table.php b/packages/Webkul/Checkout/src/Database/Migrations/2018_09_05_150444_create_cart_table.php
index be526e01e..dfe93a40a 100644
--- a/packages/Webkul/Checkout/src/Database/Migrations/2018_09_05_150444_create_cart_table.php
+++ b/packages/Webkul/Checkout/src/Database/Migrations/2018_09_05_150444_create_cart_table.php
@@ -26,16 +26,24 @@ class CreateCartTable extends Migration
$table->integer('items_count')->nullable();
$table->decimal('items_qty', 12, 4)->nullable();
$table->decimal('exchange_rate', 12, 4)->nullable();
+
$table->string('global_currency_code')->nullable();
$table->string('base_currency_code')->nullable();
$table->string('channel_currency_code')->nullable();
$table->string('cart_currency_code')->nullable();
+
$table->decimal('grand_total', 12, 4)->default(0)->nullable();
$table->decimal('base_grand_total', 12, 4)->default(0)->nullable();
+
$table->decimal('sub_total', 12, 4)->default(0)->nullable();
$table->decimal('base_sub_total', 12, 4)->default(0)->nullable();
+
+ $table->decimal('tax_total', 12, 4)->default(0)->nullable();
+ $table->decimal('base_tax_total', 12, 4)->default(0)->nullable();
+
$table->decimal('sub_total_with_discount', 12, 4)->default(0)->nullable();
$table->decimal('base_sub_total_with_discount', 12, 4)->default(0)->nullable();
+
$table->string('checkout_method')->nullable();
$table->boolean('is_guest')->nullable();
$table->boolean('is_active')->nullable()->default(1);
diff --git a/packages/Webkul/Checkout/src/Database/Migrations/2018_09_05_150915_create_cart_items_table.php b/packages/Webkul/Checkout/src/Database/Migrations/2018_09_05_150915_create_cart_items_table.php
index 0c106ef06..897b98c4a 100644
--- a/packages/Webkul/Checkout/src/Database/Migrations/2018_09_05_150915_create_cart_items_table.php
+++ b/packages/Webkul/Checkout/src/Database/Migrations/2018_09_05_150915_create_cart_items_table.php
@@ -15,34 +15,44 @@ class CreateCartItemsTable extends Migration
{
Schema::create('cart_items', function (Blueprint $table) {
$table->increments('id');
- $table->integer('product_id')->unsigned();
- $table->foreign('product_id')->references('id')->on('products');
$table->integer('quantity')->unsigned()->default(1);
- $table->integer('cart_id')->unsigned();
- $table->foreign('cart_id')->references('id')->on('cart')->onDelete('cascade');
$table->string('sku')->nullable();
$table->string('type')->nullable();
$table->string('name')->nullable();
$table->integer('parent_id')->unsigned()->nullable();
- $table->integer('tax_category_id')->unsigned()->nullable();
- $table->foreign('tax_category_id')->references('id')->on('tax_categories');
$table->string('coupon_code')->nullable();
$table->decimal('weight', 12,4)->default(1);
$table->decimal('total_weight', 12,4)->default(0);
$table->decimal('base_total_weight', 12,4)->default(0);
+
$table->decimal('price', 12,4)->default(1);
$table->decimal('base_price', 12,4)->default(0);
$table->decimal('custom_price', 12,4)->default(0);
+
$table->decimal('total', 12,4)->default(0);
$table->decimal('base_total', 12,4)->default(0);
+
+ $table->decimal('tax_percent', 12, 4)->default(0)->nullable();
+ $table->decimal('tax_amount', 12, 4)->default(0)->nullable();
+ $table->decimal('base_tax_amount', 12, 4)->default(0)->nullable();
+
$table->decimal('total_with_discount', 12,4)->default(0);
$table->decimal('base_total_with_discount', 12,4)->default(0);
+
$table->decimal('discount_percent', 12,4)->default(0);
$table->decimal('discount_amount', 12,4)->default(0);
$table->decimal('base_discount_amount', 12,4)->default(0);
$table->boolean('no_discount')->nullable()->default(0);
+
$table->boolean('free_shipping')->nullable()->default(0);
$table->json('additional')->nullable();
+
+ $table->integer('product_id')->unsigned();
+ $table->foreign('product_id')->references('id')->on('products');
+ $table->integer('cart_id')->unsigned();
+ $table->foreign('cart_id')->references('id')->on('cart')->onDelete('cascade');
+ $table->integer('tax_category_id')->unsigned()->nullable();
+ $table->foreign('tax_category_id')->references('id')->on('tax_categories');
$table->timestamps();
});
diff --git a/packages/Webkul/Core/src/Core.php b/packages/Webkul/Core/src/Core.php
index fe9cfb457..716f842df 100644
--- a/packages/Webkul/Core/src/Core.php
+++ b/packages/Webkul/Core/src/Core.php
@@ -249,6 +249,9 @@ class Core
*/
public function currency($amount = 0)
{
+ if(is_null($amount))
+ $price = 0;
+
$currencyCode = $this->getCurrentCurrency()->code;
return currency($this->convertPrice($amount), $currencyCode);
@@ -262,9 +265,26 @@ class Core
*/
public function formatPrice($price, $currencyCode)
{
+ if(is_null($price))
+ $price = 0;
+
return currency($price, $currencyCode);
}
+ /**
+ * Format price with base currency symbol
+ *
+ * @param float $price
+ * @return string
+ */
+ public function formatBasePrice($price)
+ {
+ if(is_null($price))
+ $price = 0;
+
+ return currency($price, $this->getBaseCurrencyCode());
+ }
+
/**
* Checks if current date of the given channel (in the channel timezone) is within the range
*
diff --git a/packages/Webkul/Sales/src/Database/Migrations/2018_09_27_113154_create_orders_table.php b/packages/Webkul/Sales/src/Database/Migrations/2018_09_27_113154_create_orders_table.php
index add5ecc37..cf473522b 100644
--- a/packages/Webkul/Sales/src/Database/Migrations/2018_09_27_113154_create_orders_table.php
+++ b/packages/Webkul/Sales/src/Database/Migrations/2018_09_27_113154_create_orders_table.php
@@ -17,6 +17,7 @@ class CreateOrdersTable extends Migration
$table->increments('id');
$table->string('increment_id');
$table->string('status')->nullable();
+ $table->string('channel_name')->nullable();
$table->boolean('is_guest')->nullable();
$table->string('customer_email')->nullable();
@@ -24,6 +25,7 @@ class CreateOrdersTable extends Migration
$table->string('customer_last_name')->nullable();
$table->string('shipping_method')->nullable();
+ $table->string('shipping_title')->nullable();
$table->string('shipping_description')->nullable();
$table->string('coupon_code')->nullable();
$table->boolean('is_gift')->default(0);
diff --git a/packages/Webkul/Sales/src/Database/Migrations/2018_09_27_115029_create_shipment_items_table.php b/packages/Webkul/Sales/src/Database/Migrations/2018_09_27_115029_create_shipment_items_table.php
index 2d92a3802..20f8e3f54 100644
--- a/packages/Webkul/Sales/src/Database/Migrations/2018_09_27_115029_create_shipment_items_table.php
+++ b/packages/Webkul/Sales/src/Database/Migrations/2018_09_27_115029_create_shipment_items_table.php
@@ -23,6 +23,7 @@ class CreateShipmentItemsTable extends Migration
$table->decimal('price', 12, 4)->default(0)->nullable();
$table->decimal('base_price', 12, 4)->default(0)->nullable();
+ $table->decimal('total', 12, 4)->default(0)->nullable();
$table->decimal('base_total', 12, 4)->default(0)->nullable();
$table->integer('product_id')->unsigned()->nullable();
@@ -30,9 +31,6 @@ class CreateShipmentItemsTable extends Migration
$table->integer('order_item_id')->unsigned()->nullable();
$table->integer('shipment_id')->unsigned();
$table->foreign('shipment_id')->references('id')->on('shipments')->onDelete('cascade');
- $table->integer('parent_id')->unsigned()->nullable();
- $table->foreign('parent_id')->references('id')->on('shipment_items')->onDelete('cascade');
-
$table->json('additional')->nullable();
$table->timestamps();
});
diff --git a/packages/Webkul/Sales/src/Database/Migrations/2018_09_27_115135_create_invoices_table.php b/packages/Webkul/Sales/src/Database/Migrations/2018_09_27_115135_create_invoices_table.php
index 8499953d8..2d98c577b 100644
--- a/packages/Webkul/Sales/src/Database/Migrations/2018_09_27_115135_create_invoices_table.php
+++ b/packages/Webkul/Sales/src/Database/Migrations/2018_09_27_115135_create_invoices_table.php
@@ -15,16 +15,11 @@ class CreateInvoicesTable extends Migration
{
Schema::create('invoices', function (Blueprint $table) {
$table->increments('id');
- $table->string('increment_id');
+ $table->string('increment_id')->nullable();
$table->string('state')->nullable();
$table->boolean('email_sent')->default(0);
- $table->string('shipping_method')->nullable();
- $table->string('shipping_description')->nullable();
- $table->string('coupon_code')->nullable();
- $table->boolean('is_gift')->default(0);
- $table->integer('total_item_count')->nullable();
- $table->integer('total_qty_ordered')->nullable();
+ $table->integer('total_qty')->nullable();
$table->string('base_currency_code')->nullable();
$table->string('channel_currency_code')->nullable();
@@ -45,11 +40,8 @@ class CreateInvoicesTable extends Migration
$table->decimal('discount_amount', 12, 4)->default(0)->nullable();
$table->decimal('base_discount_amount', 12, 4)->default(0)->nullable();
- $table->integer('customer_id')->unsigned()->nullable();
- $table->string('customer_type')->nullable();
- $table->integer('channel_id')->unsigned()->nullable();
- $table->string('channel_type')->nullable();
- $table->foreign('channel_id')->references('id')->on('channels')->onDelete('set null');
+ $table->integer('order_id')->unsigned()->nullable();
+ $table->foreign('order_id')->references('id')->on('orders')->onDelete('cascade');
$table->integer('order_address_id')->unsigned()->nullable();
$table->foreign('order_address_id')->references('id')->on('order_address')->onDelete('set null');
$table->timestamps();
diff --git a/packages/Webkul/Sales/src/Database/Migrations/2018_09_27_115144_create_invoice_items_table.php b/packages/Webkul/Sales/src/Database/Migrations/2018_09_27_115144_create_invoice_items_table.php
index 93b98a143..253286080 100644
--- a/packages/Webkul/Sales/src/Database/Migrations/2018_09_27_115144_create_invoice_items_table.php
+++ b/packages/Webkul/Sales/src/Database/Migrations/2018_09_27_115144_create_invoice_items_table.php
@@ -35,7 +35,7 @@ class CreateInvoiceItemsTable extends Migration
$table->integer('invoice_id')->unsigned()->nullable();
$table->foreign('invoice_id')->references('id')->on('invoices')->onDelete('cascade');
$table->integer('parent_id')->unsigned()->nullable();
- $table->foreign('parent_id')->references('id')->on('shipment_items')->onDelete('cascade');
+ $table->foreign('parent_id')->references('id')->on('invoice_items')->onDelete('cascade');
$table->json('additional')->nullable();
$table->timestamps();
diff --git a/packages/Webkul/Sales/src/Models/Invoice.php b/packages/Webkul/Sales/src/Models/Invoice.php
index 35a8d782d..de93d73c7 100644
--- a/packages/Webkul/Sales/src/Models/Invoice.php
+++ b/packages/Webkul/Sales/src/Models/Invoice.php
@@ -7,6 +7,30 @@ use Webkul\Sales\Contracts\Invoice as InvoiceContract;
class Invoice extends Model implements InvoiceContract
{
+ protected $guarded = ['id', 'created_at', 'updated_at'];
+
+ protected $statusLabel = [
+ 'pending' => 'Pending',
+ 'paid' => 'Paid',
+ 'refunded' => 'Refunded',
+ ];
+
+ /**
+ * Returns the status label from status code
+ */
+ public function getStatusLabelAttribute()
+ {
+ return isset($this->statusLabel[$this->state]) ? $this->statusLabel[$this->state] : '';
+ }
+
+ /**
+ * Get the order that belongs to the invoice.
+ */
+ public function order()
+ {
+ return $this->belongsTo(OrderProxy::modelClass());
+ }
+
/**
* Get the invoice items record associated with the invoice.
*/
@@ -31,42 +55,10 @@ class Invoice extends Model implements InvoiceContract
}
/**
- * Get the addresses for the invoice.
+ * Get the addresses for the shipment.
*/
- public function addresses()
+ public function address()
{
- return $this->hasMany(OrderAddressProxy::modelClass());
- }
-
- /**
- * Get the biling address for the invoice.
- */
- public function billing_address()
- {
- return $this->addresses()->where('address_type', 'billing');
- }
-
- /**
- * Get billing address for the invoice.
- */
- public function getBillingAddressAttribute()
- {
- return $this->billing_address()->first();
- }
-
- /**
- * Get the shipping address for the invoice.
- */
- public function shipping_address()
- {
- return $this->addresses()->where('address_type', 'shipping');
- }
-
- /**
- * Get shipping address for the invoice.
- */
- public function getShippingAddressAttribute()
- {
- return $this->shipping_address()->first();
+ return $this->belongsTo(OrderAddressProxy::modelClass(), 'order_address_id');
}
}
\ No newline at end of file
diff --git a/packages/Webkul/Sales/src/Models/InvoiceItem.php b/packages/Webkul/Sales/src/Models/InvoiceItem.php
index 908096afd..d59513356 100644
--- a/packages/Webkul/Sales/src/Models/InvoiceItem.php
+++ b/packages/Webkul/Sales/src/Models/InvoiceItem.php
@@ -7,6 +7,8 @@ use Webkul\Sales\Contracts\InvoiceItem as InvoiceItemContract;
class InvoiceItem extends Model implements InvoiceItemContract
{
+ protected $guarded = ['id', 'created_at', 'updated_at'];
+
/**
* Get the invoice record associated with the invoice item.
*/
@@ -36,6 +38,6 @@ class InvoiceItem extends Model implements InvoiceItemContract
*/
public function child()
{
- return $this->belongsTo(InvoiceItemProxy::modelClass(), 'parent_id');
+ return $this->hasOne(InvoiceItemProxy::modelClass(), 'parent_id');
}
}
\ No newline at end of file
diff --git a/packages/Webkul/Sales/src/Models/Order.php b/packages/Webkul/Sales/src/Models/Order.php
index 7c30a7723..9bb83b3f5 100644
--- a/packages/Webkul/Sales/src/Models/Order.php
+++ b/packages/Webkul/Sales/src/Models/Order.php
@@ -7,7 +7,29 @@ use Webkul\Sales\Contracts\Order as OrderContract;
class Order extends Model implements OrderContract
{
- protected $guarded = ['id', 'items', 'shipping_address', 'billing_address', 'payment', 'created_at', 'updated_at'];
+ protected $guarded = ['id', 'items', 'shipping_address', 'billing_address', 'channel', 'payment', 'created_at', 'updated_at'];
+
+ protected $statusLabel = [
+ 'pending' => 'Pending',
+ 'processing' => 'Processing',
+ 'canceled' => 'Canceled',
+ 'closed' => 'Closed',
+ ];
+
+ /**
+ * Get the order items record associated with the order.
+ */
+ public function getCustomerFullNameAttribute() {
+ return $this->customer_first_name . ' ' . $this->customer_last_name;
+ }
+
+ /**
+ * Returns the status label from status code
+ */
+ public function getStatusLabelAttribute()
+ {
+ return $this->statusLabel[$this->status];
+ }
/**
* Get the order items record associated with the order.
@@ -51,7 +73,7 @@ class Order extends Model implements OrderContract
*/
public function payment()
{
- return $this->hasMany(OrderPaymentProxy::modelClass());
+ return $this->hasOne(OrderPaymentProxy::modelClass());
}
/**
@@ -93,4 +115,32 @@ class Order extends Model implements OrderContract
{
return $this->morphTo();
}
+
+ /**
+ * Checks if new shipment is allow or not
+ */
+ public function canShip()
+ {
+ foreach ($this->items as $item) {
+ if ($item->qty_to_ship > 0) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Checks if new invoice is allow or not
+ */
+ public function canInvoice()
+ {
+ foreach ($this->items as $item) {
+ if ($item->qty_to_invoice > 0) {
+ return true;
+ }
+ }
+
+ return false;
+ }
}
\ No newline at end of file
diff --git a/packages/Webkul/Sales/src/Models/OrderItem.php b/packages/Webkul/Sales/src/Models/OrderItem.php
index 795bee0f5..789bd61bd 100644
--- a/packages/Webkul/Sales/src/Models/OrderItem.php
+++ b/packages/Webkul/Sales/src/Models/OrderItem.php
@@ -9,6 +9,20 @@ class OrderItem extends Model implements OrderItemContract
{
protected $guarded = ['id', 'child', 'created_at', 'updated_at'];
+ /**
+ * Get remaining qty for shipping.
+ */
+ public function getQtyToShipAttribute() {
+ return $this->qty_ordered - $this->qty_shipped - $this->qty_refunded;
+ }
+
+ /**
+ * Get remaining qty for invoice.
+ */
+ public function getQtyToInvoiceAttribute() {
+ return $this->qty_ordered - $this->qty_invoiced - $this->qty_refunded;
+ }
+
/**
* Get the order record associated with the order item.
*/
@@ -30,13 +44,27 @@ class OrderItem extends Model implements OrderItemContract
*/
public function child()
{
- return $this->belongsTo(OrderItemProxy::modelClass(), 'parent_id');
+ return $this->hasOne(OrderItemProxy::modelClass(), 'parent_id');
}
/**
* Get the inventories record associated with the order item.
*/
public function inventories() {
- return $this->hasMany(CartItemInventoyrProxy::modelClass());
+ return $this->hasMany(CartItemInventoryProxy::modelClass());
+ }
+
+ /**
+ * Get the invoice items record associated with the order item.
+ */
+ public function invoice_items() {
+ return $this->hasMany(InvoiceItemProxy::modelClass());
+ }
+
+ /**
+ * Get the shipment items record associated with the order item.
+ */
+ public function shipment_items() {
+ return $this->hasMany(ShipmentItemProxy::modelClass());
}
}
\ No newline at end of file
diff --git a/packages/Webkul/Sales/src/Models/Shipment.php b/packages/Webkul/Sales/src/Models/Shipment.php
index ae6d7f9b2..15baba7df 100644
--- a/packages/Webkul/Sales/src/Models/Shipment.php
+++ b/packages/Webkul/Sales/src/Models/Shipment.php
@@ -7,11 +7,21 @@ use Webkul\Sales\Contracts\Shipment as ShipmentContract;
class Shipment extends Model implements ShipmentContract
{
+ protected $guarded = ['id', 'created_at', 'updated_at'];
+
+ /**
+ * Get the order that belongs to the invoice.
+ */
+ public function order()
+ {
+ return $this->belongsTo(OrderProxy::modelClass());
+ }
+
/**
* Get the shipment items record associated with the shipment.
*/
public function items() {
- return $this->hasMany(ShipmentItemProxy::modelClass())->whereNull('parent_id');
+ return $this->hasMany(ShipmentItemProxy::modelClass());
}
/**
@@ -25,40 +35,8 @@ class Shipment extends Model implements ShipmentContract
/**
* Get the addresses for the shipment.
*/
- public function addresses()
+ public function address()
{
- return $this->hasMany(OrderAddressProxy::modelClass());
- }
-
- /**
- * Get the biling address for the shipment.
- */
- public function billing_address()
- {
- return $this->addresses()->where('address_type', 'billing');
- }
-
- /**
- * Get billing address for the shipment.
- */
- public function getBillingAddressAttribute()
- {
- return $this->billing_address()->first();
- }
-
- /**
- * Get the shipping address for the shipment.
- */
- public function shipping_address()
- {
- return $this->addresses()->where('address_type', 'shipping');
- }
-
- /**
- * Get shipping address for the shipment.
- */
- public function getShippingAddressAttribute()
- {
- return $this->shipping_address()->first();
+ return $this->belongsTo(OrderAddressProxy::modelClass(), 'order_address_id');
}
}
\ No newline at end of file
diff --git a/packages/Webkul/Sales/src/Models/ShipmentItem.php b/packages/Webkul/Sales/src/Models/ShipmentItem.php
index 2b849ee69..d9a4cc2d8 100644
--- a/packages/Webkul/Sales/src/Models/ShipmentItem.php
+++ b/packages/Webkul/Sales/src/Models/ShipmentItem.php
@@ -7,6 +7,8 @@ use Webkul\Sales\Contracts\ShipmentItem as ShipmentItemContract;
class ShipmentItem extends Model implements ShipmentItemContract
{
+ protected $guarded = ['id', 'child', 'created_at', 'updated_at'];
+
/**
* Get the shipment record associated with the shipment item.
*/
diff --git a/packages/Webkul/Sales/src/Models/create.blade.php b/packages/Webkul/Sales/src/Models/create.blade.php
new file mode 100644
index 000000000..481384e26
--- /dev/null
+++ b/packages/Webkul/Sales/src/Models/create.blade.php
@@ -0,0 +1,266 @@
+@extends('admin::layouts.master')
+
+@section('page_title')
+ {{ __('admin::app.sales.shipments.add-title') }}
+@stop
+
+@section('content-wrapper')
+
+@stop
\ No newline at end of file
diff --git a/packages/Webkul/Sales/src/Repositories/InvoiceRepository.php b/packages/Webkul/Sales/src/Repositories/InvoiceRepository.php
index 173305183..3837f2b42 100644
--- a/packages/Webkul/Sales/src/Repositories/InvoiceRepository.php
+++ b/packages/Webkul/Sales/src/Repositories/InvoiceRepository.php
@@ -3,7 +3,12 @@
namespace Webkul\Sales\Repositories;
use Illuminate\Container\Container as App;
+use Illuminate\Support\Facades\Event;
+use Illuminate\Support\Facades\DB;
use Webkul\Core\Eloquent\Repository;
+use Webkul\Sales\Repositories\OrderRepository as Order;
+use Webkul\Sales\Repositories\OrderItemRepository as OrderItem;
+use Webkul\Sales\Repositories\InvoiceItemRepository as InvoiceItem;
/**
* Invoice Reposotory
@@ -14,6 +19,51 @@ use Webkul\Core\Eloquent\Repository;
class InvoiceRepository extends Repository
{
+ /**
+ * OrderRepository object
+ *
+ * @var Object
+ */
+ protected $order;
+
+ /**
+ * OrderItemRepository object
+ *
+ * @var Object
+ */
+ protected $orderItem;
+
+ /**
+ * InvoiceItemRepository object
+ *
+ * @var Object
+ */
+ protected $invoiceItem;
+
+ /**
+ * Create a new repository instance.
+ *
+ * @param Webkul\Sales\Repositories\OrderRepository $order
+ * @param Webkul\Sales\Repositories\OrderItemRepository $orderItem
+ * @param Webkul\Sales\Repositories\InvoiceItemRepository $orderItem
+ * @return void
+ */
+ public function __construct(
+ Order $order,
+ OrderItem $orderItem,
+ InvoiceItem $invoiceItem,
+ App $app
+ )
+ {
+ $this->order = $order;
+
+ $this->orderItem = $orderItem;
+
+ $this->invoiceItem = $invoiceItem;
+
+ parent::__construct($app);
+ }
+
/**
* Specify Model class name
*
@@ -24,4 +74,142 @@ class InvoiceRepository extends Repository
{
return 'Webkul\Sales\Contracts\Invoice';
}
+
+ /**
+ * @param array $data
+ * @return mixed
+ */
+ public function create(array $data)
+ {
+ DB::beginTransaction();
+
+ try {
+ Event::fire('sales.invoice.save.before', $data);
+
+ $order = $this->order->find($data['order_id']);
+
+ $totalQty = array_sum($data['invoice']['items']);
+
+ $invoice = $this->model->create([
+ 'order_id' => $order->id,
+ 'total_qty' => $totalQty,
+ 'base_currency_code' => $order->base_currency_code,
+ 'channel_currency_code' => $order->channel_currency_code,
+ 'order_currency_code' => $order->order_currency_code,
+ 'order_address_id' => $order->billing_address->id,
+ ]);
+
+ foreach ($data['invoice']['items'] as $itemId => $qty) {
+ if(!$qty) continue;
+
+ $orderItem = $this->orderItem->find($itemId);
+
+ if($qty > $orderItem->qty_to_invoice)
+ $qty = $orderItem->qty_to_invoice;
+
+ $invoiceItem = $this->invoiceItem->create([
+ 'invoice_id' => $invoice->id,
+ 'order_item_id' => $orderItem->id,
+ 'name' => $orderItem->name,
+ 'sku' => $orderItem->sku,
+ 'qty' => $qty,
+ 'price' => $orderItem->price,
+ 'base_price' => $orderItem->base_price,
+ 'total' => $orderItem->price * $qty,
+ 'base_total' => $orderItem->base_price * $qty,
+ 'tax_amount' => ( ($orderItem->tax_amount / $orderItem->qty_ordered) * $qty ),
+ 'base_tax_amount' => ( ($orderItem->base_tax_amount / $orderItem->qty_ordered) * $qty ),
+ 'product_id' => $orderItem->product_id,
+ 'product_type' => $orderItem->product_type,
+ 'additional' => $orderItem->additional,
+ ]);
+
+ if($orderItem->type == 'configurable' && $orderItem->child) {
+ $childOrderItem = $orderItem->child;
+
+ $invoiceItem->child = $this->invoiceItem->create([
+ 'invoice_id' => $invoice->id,
+ 'order_item_id' => $childOrderItem->id,
+ 'parent_id' => $invoiceItem->id,
+ 'name' => $childOrderItem->name,
+ 'sku' => $childOrderItem->sku,
+ 'qty' => $qty,
+ 'price' => $childOrderItem->price,
+ 'base_price' => $childOrderItem->base_price,
+ 'total' => $childOrderItem->price * $qty,
+ 'base_total' => $childOrderItem->base_price * $qty,
+ 'tax_amount' => ( ($childOrderItem->tax_amount / $childOrderItem->qty_ordered) * $qty ),
+ 'base_tax_amount' => ( ($childOrderItem->base_tax_amount / $childOrderItem->qty_ordered) * $qty ),
+ 'product_id' => $childOrderItem->product_id,
+ 'product_type' => $childOrderItem->product_type,
+ 'additional' => $childOrderItem->additional,
+ ]);
+ }
+
+ $this->orderItem->collectTotals($orderItem);
+ }
+
+ $this->collectTotals($invoice);
+
+ $this->order->collectTotals($order);
+
+ $this->order->updateOrderStatus($order->id);
+ } catch (\Exception $e) {
+ DB::rollBack();
+
+ throw $e;
+ }
+
+ DB::commit();
+
+ Event::fire('sales.invoice.save.after', $invoice);
+
+ return $invoice;
+ }
+
+ /**
+ * @param mixed $invoice
+ * @return mixed
+ */
+ public function collectTotals($invoice)
+ {
+ $subTotal = $baseSubTotal = 0;
+ $taxAmount = $baseTaxAmount = 0;
+
+ foreach($invoice->items as $invoiceItem) {
+ $subTotal += $invoiceItem->total;
+ $baseSubTotal += $invoiceItem->base_total;
+
+ $taxAmount += $invoiceItem->tax_amount;
+ $baseTaxAmount += $invoiceItem->base_tax_amount;
+ }
+
+ $shippingAmount = $invoice->order->shipping_amount;
+ $baseShippingAmount = $invoice->order->base_shipping_amount;
+
+ if ($invoice->order->shipping_amount) {
+ foreach($invoice->order->invoices as $prevInvoice) {
+ if((float) $prevInvoice->shipping_amount) {
+ $shippingAmount = 0;
+ $baseShippingAmount = 0;
+ }
+ }
+ }
+
+ $invoice->sub_total = $subTotal;
+ $invoice->base_sub_total = $baseSubTotal;
+
+ $invoice->shipping_amount = $shippingAmount;
+ $invoice->base_shipping_amount = $baseShippingAmount;
+
+ $invoice->tax_amount = $taxAmount;
+ $invoice->base_tax_amount = $baseTaxAmount;
+
+ $invoice->grand_total = $subTotal + $taxAmount + $shippingAmount;
+ $invoice->base_grand_total = $baseSubTotal + $baseTaxAmount + $baseShippingAmount;
+
+ $invoice->save();
+
+ return $invoice;
+ }
}
\ No newline at end of file
diff --git a/packages/Webkul/Sales/src/Repositories/OrderItemRepository.php b/packages/Webkul/Sales/src/Repositories/OrderItemRepository.php
index 50b3f2d1d..30f9d5dd1 100644
--- a/packages/Webkul/Sales/src/Repositories/OrderItemRepository.php
+++ b/packages/Webkul/Sales/src/Repositories/OrderItemRepository.php
@@ -40,4 +40,42 @@ class OrderItemRepository extends Repository
return $this->model->create($data);
}
+
+ /**
+ * @param mixed $orderItem
+ * @return mixed
+ */
+ public function collectTotals($orderItem)
+ {
+ $qtyShipped = $qtyInvoiced = 0;
+ $totalInvoiced = $baseTotalInvoiced = 0;
+ $taxInvoiced = $baseTaxInvoiced = 0;
+
+ foreach($orderItem->invoice_items as $invoiceItem) {
+ $qtyInvoiced += $invoiceItem->qty;
+
+ $totalInvoiced += $invoiceItem->total;
+ $baseTotalInvoiced += $invoiceItem->base_total;
+
+ $taxInvoiced += $invoiceItem->tax_amount;
+ $baseTaxInvoiced += $invoiceItem->base_tax_amount;
+ }
+
+ foreach($orderItem->shipment_items as $shipmentItem) {
+ $qtyShipped += $shipmentItem->qty;
+ }
+
+ $orderItem->qty_shipped = $qtyShipped;
+ $orderItem->qty_invoiced = $qtyInvoiced;
+
+ $orderItem->total_invoiced = $totalInvoiced;
+ $orderItem->base_total_invoiced = $baseTotalInvoiced;
+
+ $orderItem->tax_amount_invoiced = $taxInvoiced;
+ $orderItem->base_tax_amount_invoiced = $baseTaxInvoiced;
+
+ $orderItem->save();
+
+ return $orderItem;
+ }
}
\ No newline at end of file
diff --git a/packages/Webkul/Sales/src/Repositories/OrderRepository.php b/packages/Webkul/Sales/src/Repositories/OrderRepository.php
index 25428b334..d72e8c86e 100644
--- a/packages/Webkul/Sales/src/Repositories/OrderRepository.php
+++ b/packages/Webkul/Sales/src/Repositories/OrderRepository.php
@@ -75,13 +75,21 @@ class OrderRepository extends Repository
try {
Event::fire('checkout.order.save.before', $data);
- if(isset($data['customer']) && $data['customer'] instanceof Model) {
+ if(isset($data['customer']) && $data['customer']) {
$data['customer_id'] = $data['customer']->id;
$data['customer_type'] = get_class($data['customer']);
} else {
unset($data['customer']);
}
+ if(isset($data['channel']) && $data['channel']) {
+ $data['channel_id'] = $data['channel']->id;
+ $data['channel_type'] = get_class($data['channel']);
+ $data['channel_name'] = $data['channel']->name;
+ } else {
+ unset($data['channel']);
+ }
+
$data['status'] = core()->getConfigData('paymentmethods.' . $data['payment']['method'] . '.status') ?? 'pending';
$order = $this->model->create(array_merge($data, ['increment_id' => $this->generateIncrementId()]));
@@ -125,4 +133,51 @@ class OrderRepository extends Repository
return $lastId + 1;
}
+
+ /**
+ * @param int $orderId
+ * @return void
+ */
+ public function updateOrderStatus(int $orderId)
+ {
+ $order = $this->find($orderId);
+ }
+
+ /**
+ * @param mixed $order
+ * @return mixed
+ */
+ public function collectTotals($order)
+ {
+ $subTotalInvoiced = $baseSubTotalInvoiced = 0;
+ $shippingInvoiced = $baseShippingInvoiced = 0;
+ $taxInvoiced = $baseTaxInvoiced = 0;
+
+ foreach($order->invoices as $invoice) {
+ $subTotalInvoiced += $invoice->sub_total;
+ $baseSubTotalInvoiced += $invoice->base_sub_total;
+
+ $shippingInvoiced += $invoice->shipping_amount;
+ $baseShippingInvoiced += $invoice->base_shipping_amount;
+
+ $taxInvoiced += $invoice->tax_amount;
+ $baseTaxInvoiced += $invoice->base_tax_amount;
+ }
+
+ $order->sub_total_invoiced = $subTotalInvoiced;
+ $order->base_sub_total_invoiced = $baseSubTotalInvoiced;
+
+ $order->shipping_invoiced = $shippingInvoiced;
+ $order->base_shipping_invoiced = $baseShippingInvoiced;
+
+ $order->tax_amount_invoiced = $taxInvoiced;
+ $order->base_tax_amount_invoiced = $baseTaxInvoiced;
+
+ $order->grand_total_invoiced = $subTotalInvoiced + $shippingInvoiced + $taxInvoiced;
+ $order->base_grand_total_invoiced = $baseSubTotalInvoiced + $shippingInvoiced + $baseTaxInvoiced;
+
+ $order->save();
+
+ return $order;
+ }
}
\ No newline at end of file
diff --git a/packages/Webkul/Sales/src/Repositories/ShipmentRepository.php b/packages/Webkul/Sales/src/Repositories/ShipmentRepository.php
index 4bb2ccc56..337db3169 100644
--- a/packages/Webkul/Sales/src/Repositories/ShipmentRepository.php
+++ b/packages/Webkul/Sales/src/Repositories/ShipmentRepository.php
@@ -3,7 +3,12 @@
namespace Webkul\Sales\Repositories;
use Illuminate\Container\Container as App;
+use Illuminate\Support\Facades\Event;
+use Illuminate\Support\Facades\DB;
use Webkul\Core\Eloquent\Repository;
+use Webkul\Sales\Repositories\OrderRepository as Order;
+use Webkul\Sales\Repositories\OrderItemRepository as OrderItem;
+use Webkul\Sales\Repositories\ShipmentItemRepository as ShipmentItem;
/**
* Shipment Reposotory
@@ -14,6 +19,51 @@ use Webkul\Core\Eloquent\Repository;
class ShipmentRepository extends Repository
{
+ /**
+ * OrderRepository object
+ *
+ * @var Object
+ */
+ protected $order;
+
+ /**
+ * OrderItemRepository object
+ *
+ * @var Object
+ */
+ protected $orderItem;
+
+ /**
+ * ShipmentItemRepository object
+ *
+ * @var Object
+ */
+ protected $shipmentItem;
+
+ /**
+ * Create a new repository instance.
+ *
+ * @param Webkul\Sales\Repositories\OrderRepository $order
+ * @param Webkul\Sales\Repositories\OrderItemRepository $orderItem
+ * @param Webkul\Sales\Repositories\ShipmentItemRepository $orderItem
+ * @return void
+ */
+ public function __construct(
+ Order $order,
+ OrderItem $orderItem,
+ ShipmentItem $shipmentItem,
+ App $app
+ )
+ {
+ $this->order = $order;
+
+ $this->orderItem = $orderItem;
+
+ $this->shipmentItem = $shipmentItem;
+
+ parent::__construct($app);
+ }
+
/**
* Specify Model class name
*
@@ -24,4 +74,70 @@ class ShipmentRepository extends Repository
{
return 'Webkul\Sales\Contracts\Shipment';
}
+
+ /**
+ * @param array $data
+ * @return mixed
+ */
+ public function create(array $data)
+ {
+ DB::beginTransaction();
+
+ try {
+ Event::fire('sales.shipment.save.before', $data);
+
+ $order = $this->order->find($data['order_id']);
+
+ $totalQty = array_sum($data['shipment']['items']);
+
+ $shipment = $this->model->create([
+ 'order_id' => $order->id,
+ 'total_qty' => $totalQty,
+ 'carrier_title' => $data['shipment']['carrier_title'],
+ 'track_number' => $data['shipment']['track_number'],
+ 'customer_id' => $order->customer_id,
+ 'customer_type' => $order->customer_type,
+ 'order_address_id' => $order->shipping_address->id,
+ ]);
+
+ foreach ($data['shipment']['items'] as $itemId => $qty) {
+ if(!$qty) continue;
+
+ $orderItem = $this->orderItem->find($itemId);
+
+ if($qty > $orderItem->qty_to_ship)
+ $qty = $orderItem->qty_to_ship;
+
+ $shipmentItem = $this->shipmentItem->create([
+ 'shipment_id' => $shipment->id,
+ 'order_item_id' => $orderItem->id,
+ 'name' => $orderItem->name,
+ 'sku' => ($orderItem->type == 'configurable' ? $orderItem->child->sku : $orderItem->sku),
+ 'qty' => $qty,
+ 'weight' => $orderItem->weight * $qty,
+ 'price' => $orderItem->price,
+ 'base_price' => $orderItem->base_price,
+ 'total' => $orderItem->price * $qty,
+ 'base_total' => $orderItem->base_price * $qty,
+ 'product_id' => $orderItem->product_id,
+ 'product_type' => $orderItem->product_type,
+ 'additional' => $orderItem->additional,
+ ]);
+
+ $this->orderItem->update(['qty_shipped' => $orderItem->qty_shipped + $qty], $orderItem->id);
+ }
+
+ $this->order->updateOrderStatus($order->id);
+ } catch (\Exception $e) {
+ DB::rollBack();
+
+ throw $e;
+ }
+
+ DB::commit();
+
+ Event::fire('sales.shipment.save.after', $shipment);
+
+ return $shipment;
+ }
}
\ No newline at end of file
diff --git a/packages/Webkul/Shop/src/Resources/lang/en/app.php b/packages/Webkul/Shop/src/Resources/lang/en/app.php
index 7f4684f60..2aa802a9f 100644
--- a/packages/Webkul/Shop/src/Resources/lang/en/app.php
+++ b/packages/Webkul/Shop/src/Resources/lang/en/app.php
@@ -131,6 +131,7 @@ return [
'sub-total' => 'Items',
'grand-total' => 'Grand Total',
'delivery-charges' => 'Delivery Charges',
+ 'tax' => 'Tax',
'price' => 'price'
],
diff --git a/packages/Webkul/Shop/src/Resources/views/checkout/total/summary.blade.php b/packages/Webkul/Shop/src/Resources/views/checkout/total/summary.blade.php
index 6f6583a47..65d200ef8 100644
--- a/packages/Webkul/Shop/src/Resources/views/checkout/total/summary.blade.php
+++ b/packages/Webkul/Shop/src/Resources/views/checkout/total/summary.blade.php
@@ -21,6 +21,13 @@
+
\ No newline at end of file
diff --git a/packages/Webkul/Ui/src/Resources/assets/js/components/tabs/tabs.vue b/packages/Webkul/Ui/src/Resources/assets/js/components/tabs/tabs.vue
new file mode 100644
index 000000000..fb501e0a6
--- /dev/null
+++ b/packages/Webkul/Ui/src/Resources/assets/js/components/tabs/tabs.vue
@@ -0,0 +1,37 @@
+
+
+
\ No newline at end of file
diff --git a/packages/Webkul/Ui/src/Resources/assets/sass/app.scss b/packages/Webkul/Ui/src/Resources/assets/sass/app.scss
index 23248599b..4af87b700 100644
--- a/packages/Webkul/Ui/src/Resources/assets/sass/app.scss
+++ b/packages/Webkul/Ui/src/Resources/assets/sass/app.scss
@@ -234,6 +234,10 @@ h2 {
vertical-align: middle;
}
}
+
+ &.empty {
+ text-align: center;
+ }
}
tbody tr:last-child td {
@@ -1032,562 +1036,4 @@ h2 {
background-image: none;
}
}
-}
-
-
-
-// admin dashboard component
-
- .dashboard-card {
- height: 100px;
- width: 22%;
- background: #FFFFFF;
- border: 1px solid #E7E7E7;
- box-shadow: 0 5px 10px 2px rgba(0,0,0,0.08);
- border-radius: 5px;
-
- .visitor-content {
- padding: 15px;
-
- .title {
-
- span {
- padding-top:10px;
- font-size: 14px;
- color: #A2A2A2;
- letter-spacing: -0.26px;
- }
- }
-
- .data {
- padding-top: 3px;
-
- span {
- font-size: 32px;
- color: #0041FF;
- letter-spacing: -0.6px;
-
- img {
- margin-left: 75px;
- height: 24px;
- width:24px;
- }
- }
-
- span.right {
- padding-top: 12px;
- float: right;
- font-size: 14px;
- color: #8E8E8E;
- letter-spacing: -0.7px;
- }
- }
- }
- }
-
- .dashboard-card:nth-last-child(1) {
- margin-left: 30px;
- }
-
- .dashboard-card:nth-last-child(2) {
- margin-left: 30px;
- }
-
- .dashboard-card:nth-last-child(3) {
- margin-left: 30px;
- }
-
-
- .dashboard-graph {
- height: 413px;
- width: 70.5%;
- background: #FFFFFF;
- border: 1px solid #E7E7E7;
- box-shadow: 0 5px 10px 2px rgba(0,0,0,0.08);
- border-radius: 2px;
- }
-
- .performing-category {
- height: 413px;
- width: 22%;
- margin-left: 30px;
- background: #FFFFFF;
- border: 1px solid #E7E7E7;
- box-shadow: 0 5px 10px 2px rgba(0,0,0,0.08);
- border-radius: 2px;
-
- .category {
- margin-left: 20px;
- margin-top: 20px;
-
- .title {
-
- span {
- font-size: 14px;
- color: #A2A2A2;
- letter-spacing: -0.26px;
- }
- }
-
- .category-info {
- margin-top: 30px;
-
-
- ul {
-
- li {
-
- .category-list {
- margin-top: 10px;
-
- .cat-name {
-
- span {
- font-size: 16px;
- color: #0041FF;
- letter-spacing: -0.3px;
-
- }
-
- .right-side {
- float: right;
- margin-right: 12px;
- margin-top: 10px;
- height: 20px;
- width: 20px;
- }
- }
-
- .product-info {
- margin-top: 5px;
-
- span {
- font-size: 16px;
- color: #3A3A3A;
- letter-spacing: -0.3px;
- }
- }
-
- .horizon-rule {
- margin-top: 8px;
- border: .7px solid #D8D8D8;
- }
- }
- }
-
- li:last-child {
-
- .category-list {
- .horizon-rule {
- display: none;
- }
- }
- }
- }
- }
- }
- }
-
- .sale {
- height: 465px;
- width: 30.1%;
- background: #FFFFFF;
- border: 1px solid #E7E7E7;
- box-shadow: 0 5px 10px 2px rgba(0,0,0,0.08);
- border-radius: 2px;
-
- .top-sale {
- margin-left: 20px;
- margin-top: 27px;
-
- .title {
-
- span {
- font-size: 14px;
- color: #A2A2A2;
- letter-spacing: -0.26px;
- }
- }
-
- .sale-info {
-
- ul {
-
- li {
-
- .pro-attribute{
- display: flex;
- margin-top: 10px;
-
- .pro-img {
- height: 60px;
- width: 60px;
- border: 1px solid green;
- }
-
- .product-description {
- margin-left: 15px;
- margin-top: 8px;
- width: 75%;
-
- .product-name {
-
- span {
- font-size: 14px;
- color: #0041FF;
- letter-spacing: -0.26px;
- }
-
- .right-side {
- float: right;
- margin-top: 10px;
- height: 20px;
- width: 20px;
- }
- }
-
- .product-info {
-
- span {
- font-size: 14px;
- color: #3A3A3A;
- letter-spacing: -0.26px;
- }
- }
- }
- }
-
- .horizontal-rule {
- border: .5px solid #A2A2A2;
- opacity: 0.2;
- margin-top: 10px;
- }
- }
-
- li:last-child {
- .horizontal-rule {
- display: none;
- }
- }
- }
- }
- }
- }
-
- .sale:nth-last-child(1) {
- margin-left: 31px;
- }
-
- .sale:nth-last-child(2) {
- margin-left: 31px;
- }
-
- // admin dashboard css ends here
-
-
- // customer order information for admin css start here
-
- .order-information {
-
- .order-info {
-
- span{
- font-size: 18px;
- color: #8E8E8E;
- letter-spacing: -0.29px;
- }
-
- .edit {
- float :right;
- font-size: 16px;
- color: #0041FF;
- letter-spacing: -0.29px;
- text-align: right;
- }
- }
-
- .horizotal-rule {
- width:100%;
- border:1px solid #A2A2A2;
- opacity: 0.2;
- margin-top: 16px;
- }
-
- .order-account{
- display:flex;
- flex-direction: row;
- margin-top: 20px;
-
- .left-content {
- width: 200px;
-
- span {
- font-size: 16px;
- color: #3A3A3A;
- letter-spacing: -0.26px;
- }
- }
-
- .right-content {
-
- span {
- font-size: 16px;
- color: #3A3A3A;
- letter-spacing: -0.26px;
- }
- }
- }
- }
-
- .account-information {
- margin-top: 30px;
-
- .account-info {
-
- span{
- font-size: 18px;
- color: #8E8E8E;
- letter-spacing: -0.29px;
- }
-
- .edit {
- float :right;
- font-size: 16px;
- color: #0041FF;
- letter-spacing: -0.29px;
- text-align: right;
- }
- }
-
- .horizotal-rule {
- width:100%;
- border:1px solid #A2A2A2;
- opacity: 0.2;
- margin-top: 16px;
- }
-
- .order-account{
- display:flex;
- flex-direction: row;
- margin-top: 20px;
-
- .left-content {
- width: 200px;
-
- span {
- font-size: 16px;
- color: #3A3A3A;
- letter-spacing: -0.26px;
- }
-
- }
-
- .right-content {
-
- span {
- font-size: 16px;
- color: #3A3A3A;
- letter-spacing: -0.26px;
- }
-
- .name {
- color: #0041FF;
- }
- }
- }
- }
-
- .address-information {
-
- .address-name {
-
- span{
- font-size: 18px;
- color: #8E8E8E;
- letter-spacing: -0.29px;
- }
-
- .edit {
- float :right;
- font-size: 16px;
- color: #0041FF;
- letter-spacing: -0.29px;
- text-align: right;
- }
- }
-
- .horizotal-rule {
- width:100%;
- border:1px solid #A2A2A2;
- opacity: 0.2;
- margin-top: 16px;
- }
-
- .address-detail{
- margin-top: 10px;
-
- span {
- font-size: 16px;
- color: #3A3A3A;
- letter-spacing: -0.26px;
- display: block;
- }
- }
- }
-
- .address-information:last-child {
- margin-top: 15px;
- }
-
- .payment-information {
-
- .title {
-
- span{
- font-size: 18px;
- color: #8E8E8E;
- letter-spacing: -0.29px;
- }
- }
-
- .horizotal-rule {
- width:100%;
- border:1px solid #A2A2A2;
- opacity: 0.2;
- margin-top: 16px;
- }
-
- .payment-info{
- display:flex;
- flex-direction: row;
- margin-top: 20px;
-
- .left-content {
- width: 200px;
-
- span {
- font-size: 16px;
- color: #3A3A3A;
- letter-spacing: -0.26px;
- }
- }
-
- .right-content {
-
- span {
- font-size: 16px;
- color: #3A3A3A;
- letter-spacing: -0.26px;
- }
- }
- }
- }
-
- .payment-information:last-child {
- margin-top: 25px;
- }
-
- .total {
- margin-top: 2%;
- height: 130px;
-
- .calculate {
- margin-right: 8%;
- float: right;
-
- .sub-total {
-
- span {
- font-size: 14px; font-size: 14px;
- color: #3A3A3A;
- color: #3A3A3A;
- }
-
- .left {
- margin-left: 109px;
- }
-
- .middle {
- margin-right: 5px;
- margin-left: 5px;
- }
- }
-
- .ship-handle {
- margin-top: 5px;
-
- span {
- font-size: 14px;
- color: #3A3A3A;
- }
-
- .left {
- margin-left: 24px;
- }
-
- .middle {
- margin-right: 5px;
- margin-left: 5px;
- }
- }
-
- .discount {
- margin-top: 5px;
-
- span {
- font-size: 14px; font-size: 14px;
- color: #3A3A3A;
- }
-
- .left {
- margin-left: 98px;
- }
-
- .middle {
- margin-right: 5px;
- margin-left: 5px;
- }
- }
-
- .grand-total {
- margin-top: 5px;
-
- span {
- font-size: 14px; font-size: 14px;
- color: #3A3A3A;
- font-weight: bold;
- }
-
- .left {
- margin-left: 87px;
- }
-
- .middle {
- margin-right: 5px;
- margin-left: 5px;
- }
- }
-
- .due {
- margin-top: 5px;
-
- span {
- font-size: 14px; font-size: 14px;
- color: #3A3A3A;
- font-weight: bold;
- }
-
- .left {
- margin-left: 101px;
- }
-
- .middle {
- margin-right: 5px;
- margin-left: 5px;
- }
- }
- }
- }
-
-
- // customer order information for admin css end here
+}
\ No newline at end of file
diff --git a/packages/Webkul/Ui/src/Resources/assets/sass/icons.scss b/packages/Webkul/Ui/src/Resources/assets/sass/icons.scss
index 4619c3f45..cd5f00ab3 100644
--- a/packages/Webkul/Ui/src/Resources/assets/sass/icons.scss
+++ b/packages/Webkul/Ui/src/Resources/assets/sass/icons.scss
@@ -14,6 +14,10 @@
@extend %menu-properties;
background-image: url("../images/Icon-Dashboard.svg");
}
+.sales-icon {
+ @extend %menu-properties;
+ background-image: url("../images/Icon-Sales.svg");
+}
.catalog-icon {
@extend %menu-properties;
background-image: url("../images/Icon-Catalog.svg");
@@ -179,6 +183,10 @@
background-image: url("../images/Icon-Dashboard-Active.svg");
}
+ .sales-icon {
+ background-image: url("../images/Icon-Sales-Active.svg");
+ }
+
.catalog-icon {
background-image: url("../images/Icon-Catalog-Active.svg");
}
@@ -205,6 +213,10 @@
background-image: url("../images/Icon-Dashboard-Active.svg");
}
+ &.sales-icon {
+ background-image: url("../images/Icon-Sales-Active.svg");
+ }
+
&.settings-icon {
background-image: url("../images/Icon-Settings-Active.svg");
}