From 8a463e7b9ed7866fb56a9734e580549f16415d71 Mon Sep 17 00:00:00 2001 From: ludo Date: Thu, 21 Dec 2023 23:04:42 +0100 Subject: [PATCH] update payments and vat mentions --- app/Http/Controllers/Shop/OrderController.php | 5 +- app/Models/Shop/PriceListValue.php | 5 + app/Repositories/Shop/Baskets.php | 1 + .../Shop/DeliveryTypeCalculations.php | 2 +- app/Repositories/Shop/Orders.php | 3 +- .../Admin/Shop/InvoicePayments/edit.blade.php | 95 ------------------- .../Admin/Shop/InvoicePayments/form.blade.php | 25 ++++- .../Shop/InvoicePayments/index.blade.php | 5 +- .../views/Admin/Shop/Invoices/form.blade.php | 9 +- .../Shop/Invoices/partials/payments.blade.php | 6 +- .../views/Admin/Shop/Orders/create.blade.php | 39 ++++---- .../views/Admin/Shop/Orders/edit.blade.php | 15 ++- .../Shop/Orders/partials/detail.blade.php | 19 ++-- 13 files changed, 86 insertions(+), 143 deletions(-) delete mode 100644 resources/views/Admin/Shop/InvoicePayments/edit.blade.php diff --git a/app/Http/Controllers/Shop/OrderController.php b/app/Http/Controllers/Shop/OrderController.php index 4b79fe3e..f73aa2bc 100644 --- a/app/Http/Controllers/Shop/OrderController.php +++ b/app/Http/Controllers/Shop/OrderController.php @@ -50,9 +50,6 @@ class OrderController extends Controller 'delivery_types' => DeliveryTypes::getWithPrice(Baskets::getWeight()), ]; - // dump($data); - // exit; - return view('Shop.Orders.order', $data); } else { return redirect()->route('home'); @@ -64,7 +61,7 @@ class OrderController extends Controller $data = $request->all(); $data['customer_id'] = Customers::getId(); $data['sale_channel_id'] = $data['sale_channel_id'] ?? SaleChannels::getDefaultID(); - $data['basket'] = Baskets::getBasketSummary($data['sale_channel_id']); + $data['basket'] = Baskets::getBasketSummary($data['sale_channel_id'], $data['delivery_type_id'] ?? false); $order = Orders::saveOrder($data); if ($order) { if ($data['payment_type'] == '1') { diff --git a/app/Models/Shop/PriceListValue.php b/app/Models/Shop/PriceListValue.php index 5f91450f..f38fd7a1 100644 --- a/app/Models/Shop/PriceListValue.php +++ b/app/Models/Shop/PriceListValue.php @@ -30,6 +30,11 @@ class PriceListValue extends Model ); } + public function vat() + { + return $this->belongsTo(Tax::class, 'tax_id'); + } + public function scopeByPriceList($query, $id) { return $query->where($this->table.'.price_list_id', $id); diff --git a/app/Repositories/Shop/Baskets.php b/app/Repositories/Shop/Baskets.php index 03fedeac..a8561965 100644 --- a/app/Repositories/Shop/Baskets.php +++ b/app/Repositories/Shop/Baskets.php @@ -64,6 +64,7 @@ class Baskets 'offer_id' => (int) $item->id, 'name' => $offer->article->name.' ('.$offer->variation->name.')', 'quantity' => (int) $item->quantity, + 'vat' => $prices ? (float) $prices->vat->value : false, 'price' => $prices ? (float) $prices->price : false, 'tax' => $prices ? $prices->price_taxed - $prices->price : false, 'price_taxed' => $prices ? (float) $prices->price_taxed : false, diff --git a/app/Repositories/Shop/DeliveryTypeCalculations.php b/app/Repositories/Shop/DeliveryTypeCalculations.php index 887c51bb..a61b8fd8 100644 --- a/app/Repositories/Shop/DeliveryTypeCalculations.php +++ b/app/Repositories/Shop/DeliveryTypeCalculations.php @@ -13,7 +13,7 @@ class DeliveryTypeCalculations { $price = DeliveryTypeCalculation::byDeliveryType($deliveryTypeId)->byWeight($weight)->first(); - return $price ? $price->price : false; + return $price ? (float) $price->price : false; } public static function getModel() diff --git a/app/Repositories/Shop/Orders.php b/app/Repositories/Shop/Orders.php index 50409c4e..105531d9 100644 --- a/app/Repositories/Shop/Orders.php +++ b/app/Repositories/Shop/Orders.php @@ -5,6 +5,7 @@ namespace App\Repositories\Shop; use App\Models\Shop\Order; use App\Repositories\Core\DateStats; use App\Traits\Model\Basic; +use Illuminate\Support\Arr; use Illuminate\Support\Str; class Orders @@ -41,7 +42,7 @@ class Orders $data += self::getSummaryOfBasket($basket); $order = self::store($data); $detail = $order ? OrderDetails::saveBasket($order->id, $basket['detail']) : false; - unset($data['comment'], $data['agree'], $data['delivery_address_id'], $data['sale_channel_id']); + $data = Arr::except($data, ['comment', 'agree', 'delivery_address_id', 'sale_channel_id', 'delivery_id', 'delivery_type_id']); $invoice = $detail ? Invoices::saveInvoice($order->id, $data + $invoice) : false; return $invoice ? $order : false; diff --git a/resources/views/Admin/Shop/InvoicePayments/edit.blade.php b/resources/views/Admin/Shop/InvoicePayments/edit.blade.php deleted file mode 100644 index e92aa958..00000000 --- a/resources/views/Admin/Shop/InvoicePayments/edit.blade.php +++ /dev/null @@ -1,95 +0,0 @@ -@extends('layout.index', [ - 'title' => 'Factures', - 'subtitle' => 'Edition d\'une facture', - 'breadcrumb' => ['Articles'], -]) - -@include('boilerplate::load.fileinput') - -@section('content') -
-
- {{ Form::open(['route' => 'Admin.Shop.Invoices.update', 'id' => 'invoice-form', 'autocomplete' => 'off']) }} - - -
-
-

-
-
- @include('components.form.buttons.button-save') -
-
- -
-
-

- {{ $invoice['order']['customer']['last_name'] }} - {{ $invoice['order']['customer']['first_name'] }} -

-
-
-
- @if ($invoice['order']['delivery_address']) - {{ $invoice['order']['delivery_address']['address'] }}
- @isset($invoice['order']['delivery_address']['address2']) - {{ $invoice['order']['delivery_address']['address2'] }}
- @endisset - {{ $invoice['order']['delivery_address']['zipcode'] }} - {{ $invoice['order']['delivery_address']['city'] }}
- @endif -
-
-
-
-
-
-
- Facture N° {{ $invoice['ref'] }}
- du {{ Carbon\Carbon::parse($invoice['created_at'])->isoFormat('LLLL') }} -
-
- -
-
-
-
- @include('components.form.select', [ - 'label' => 'Statut', - 'name' => 'status', - 'list' => $statuses ?? [], - 'value' => $invoice['status'], - 'class' => 'select2', - ]) -
-
- @include('components.form.select', [ - 'label' => 'Règlement', - 'name' => 'payment_type', - 'list' => $payment_types ?? [], - 'value' => $invoice['order']['payment_type'], - 'class' => 'select2', - 'disabled' => false, - ]) -
-
-
-
-
-
- @include('Admin.Shop.Orders.partials.detail', [ - 'detail_type' => 'facture', - 'order' => $invoice['order'], - ]) -
-
-
- -
-
- -

Règlements

-
-
-
-@endsection diff --git a/resources/views/Admin/Shop/InvoicePayments/form.blade.php b/resources/views/Admin/Shop/InvoicePayments/form.blade.php index b204386e..e9b9f98c 100644 --- a/resources/views/Admin/Shop/InvoicePayments/form.blade.php +++ b/resources/views/Admin/Shop/InvoicePayments/form.blade.php @@ -1,12 +1,17 @@ +f{{ Form::open(['route' => 'Admin.Shop.InvoicePayments.store', 'id' => 'invoice_payment-form', 'autocomplete' => 'off']) }} + +
-
+
@include('components.form.datepicker', [ 'label' => 'Date', 'name' => 'date', 'value' => $invoice_payment['date'] ?? null, ])
-
+
+
+
@include('components.form.select', [ 'label' => 'Règlement', 'name' => 'payment_type', @@ -17,7 +22,7 @@
-
+
@include('components.form.inputs.money', [ 'label' => 'Montant', 'name' => 'amount', @@ -25,3 +30,17 @@ ])
+
+
+ @include('components.form.input', [ + 'label' => 'Référence', + 'name' => 'reference', + 'value' => $invoice_payment['reference'] ?? null, + ]) +
+
+ + + diff --git a/resources/views/Admin/Shop/InvoicePayments/index.blade.php b/resources/views/Admin/Shop/InvoicePayments/index.blade.php index a2c9f4c9..d21d889f 100644 --- a/resources/views/Admin/Shop/InvoicePayments/index.blade.php +++ b/resources/views/Admin/Shop/InvoicePayments/index.blade.php @@ -6,9 +6,6 @@ @section('content') - @include('components.datatable', [ - 'route' => route('Admin.Shop.InvoicePayments.index'), - 'model' => 'invoice_payments', - ]) + @include('Admin.Shop.InvoicePayments.list') @endsection diff --git a/resources/views/Admin/Shop/Invoices/form.blade.php b/resources/views/Admin/Shop/Invoices/form.blade.php index 6e9a1509..1d19393f 100644 --- a/resources/views/Admin/Shop/Invoices/form.blade.php +++ b/resources/views/Admin/Shop/Invoices/form.blade.php @@ -4,7 +4,7 @@
- + Facture N° {{ $invoice['ref'] }} @@ -20,12 +20,11 @@
+ @if ($invoice['order']['customer']['company']) + Société : {{ $invoice['order']['customer']['company'] }}
+ @endif {{ $invoice['order']['customer']['first_name'] }} {{ $invoice['order']['customer']['last_name'] }} - @if ($invoice['order']['customer']['company']) -
- {{ $invoice['order']['customer']['company'] }} - @endif
@if ($invoice['order']['delivery_address']) diff --git a/resources/views/Admin/Shop/Invoices/partials/payments.blade.php b/resources/views/Admin/Shop/Invoices/partials/payments.blade.php index d225f232..e79fba5f 100644 --- a/resources/views/Admin/Shop/Invoices/partials/payments.blade.php +++ b/resources/views/Admin/Shop/Invoices/partials/payments.blade.php @@ -27,6 +27,8 @@ @endif +@include('load.form.datepicker') + @push('js')