update payments and vat mentions

This commit is contained in:
ludo
2023-12-21 23:04:42 +01:00
parent 643c26d549
commit 8a463e7b9e
13 changed files with 86 additions and 143 deletions

View File

@@ -50,9 +50,6 @@ class OrderController extends Controller
'delivery_types' => DeliveryTypes::getWithPrice(Baskets::getWeight()), 'delivery_types' => DeliveryTypes::getWithPrice(Baskets::getWeight()),
]; ];
// dump($data);
// exit;
return view('Shop.Orders.order', $data); return view('Shop.Orders.order', $data);
} else { } else {
return redirect()->route('home'); return redirect()->route('home');
@@ -64,7 +61,7 @@ class OrderController extends Controller
$data = $request->all(); $data = $request->all();
$data['customer_id'] = Customers::getId(); $data['customer_id'] = Customers::getId();
$data['sale_channel_id'] = $data['sale_channel_id'] ?? SaleChannels::getDefaultID(); $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); $order = Orders::saveOrder($data);
if ($order) { if ($order) {
if ($data['payment_type'] == '1') { if ($data['payment_type'] == '1') {

View File

@@ -30,6 +30,11 @@ class PriceListValue extends Model
); );
} }
public function vat()
{
return $this->belongsTo(Tax::class, 'tax_id');
}
public function scopeByPriceList($query, $id) public function scopeByPriceList($query, $id)
{ {
return $query->where($this->table.'.price_list_id', $id); return $query->where($this->table.'.price_list_id', $id);

View File

@@ -64,6 +64,7 @@ class Baskets
'offer_id' => (int) $item->id, 'offer_id' => (int) $item->id,
'name' => $offer->article->name.' ('.$offer->variation->name.')', 'name' => $offer->article->name.' ('.$offer->variation->name.')',
'quantity' => (int) $item->quantity, 'quantity' => (int) $item->quantity,
'vat' => $prices ? (float) $prices->vat->value : false,
'price' => $prices ? (float) $prices->price : false, 'price' => $prices ? (float) $prices->price : false,
'tax' => $prices ? $prices->price_taxed - $prices->price : false, 'tax' => $prices ? $prices->price_taxed - $prices->price : false,
'price_taxed' => $prices ? (float) $prices->price_taxed : false, 'price_taxed' => $prices ? (float) $prices->price_taxed : false,

View File

@@ -13,7 +13,7 @@ class DeliveryTypeCalculations
{ {
$price = DeliveryTypeCalculation::byDeliveryType($deliveryTypeId)->byWeight($weight)->first(); $price = DeliveryTypeCalculation::byDeliveryType($deliveryTypeId)->byWeight($weight)->first();
return $price ? $price->price : false; return $price ? (float) $price->price : false;
} }
public static function getModel() public static function getModel()

View File

@@ -5,6 +5,7 @@ namespace App\Repositories\Shop;
use App\Models\Shop\Order; use App\Models\Shop\Order;
use App\Repositories\Core\DateStats; use App\Repositories\Core\DateStats;
use App\Traits\Model\Basic; use App\Traits\Model\Basic;
use Illuminate\Support\Arr;
use Illuminate\Support\Str; use Illuminate\Support\Str;
class Orders class Orders
@@ -41,7 +42,7 @@ class Orders
$data += self::getSummaryOfBasket($basket); $data += self::getSummaryOfBasket($basket);
$order = self::store($data); $order = self::store($data);
$detail = $order ? OrderDetails::saveBasket($order->id, $basket['detail']) : false; $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; $invoice = $detail ? Invoices::saveInvoice($order->id, $data + $invoice) : false;
return $invoice ? $order : false; return $invoice ? $order : false;

View File

@@ -1,95 +0,0 @@
@extends('layout.index', [
'title' => 'Factures',
'subtitle' => 'Edition d\'une facture',
'breadcrumb' => ['Articles'],
])
@include('boilerplate::load.fileinput')
@section('content')
<div class="row">
<div class="col-8">
{{ Form::open(['route' => 'Admin.Shop.Invoices.update', 'id' => 'invoice-form', 'autocomplete' => 'off']) }}
<input type="hidden" name="id" value="{{ $invoice['id'] }}">
<x-card>
<div class="row">
<div class="col-6">
<h4> </h4>
</div>
<div class="col-6 text-right">
@include('components.form.buttons.button-save')
</div>
</div>
<div class="row mb-3">
<div class="col-6">
<h3>
{{ $invoice['order']['customer']['last_name'] }}
{{ $invoice['order']['customer']['first_name'] }}
</h3>
<div class="row">
<div class="col-12">
<h6>
@if ($invoice['order']['delivery_address'])
{{ $invoice['order']['delivery_address']['address'] }}<br />
@isset($invoice['order']['delivery_address']['address2'])
{{ $invoice['order']['delivery_address']['address2'] }}<br />
@endisset
{{ $invoice['order']['delivery_address']['zipcode'] }}
{{ $invoice['order']['delivery_address']['city'] }}<br />
@endif
</h6>
</div>
</div>
</div>
<div class="col-6">
<div class="row mb-3">
<div class="col-6" style="font-size: 1.2em; font-weight: 500;">
Facture {{ $invoice['ref'] }}<br />
du {{ Carbon\Carbon::parse($invoice['created_at'])->isoFormat('LLLL') }}
</div>
<div class="col-6">
</div>
</div>
<div class="row mb-3">
<div class="col-6">
@include('components.form.select', [
'label' => 'Statut',
'name' => 'status',
'list' => $statuses ?? [],
'value' => $invoice['status'],
'class' => 'select2',
])
</div>
<div class="col-6">
@include('components.form.select', [
'label' => 'Règlement',
'name' => 'payment_type',
'list' => $payment_types ?? [],
'value' => $invoice['order']['payment_type'],
'class' => 'select2',
'disabled' => false,
])
</div>
</div>
</div>
</div>
<div class="row mb-3">
<div class="col-12">
@include('Admin.Shop.Orders.partials.detail', [
'detail_type' => 'facture',
'order' => $invoice['order'],
])
</div>
</div>
</x-card>
</form>
</div>
<div class="col-4">
<x-card>
<h4>Règlements</h4>
</x-card>
</div>
</div>
@endsection

View File

@@ -1,12 +1,17 @@
f{{ Form::open(['route' => 'Admin.Shop.InvoicePayments.store', 'id' => 'invoice_payment-form', 'autocomplete' => 'off']) }}
<input type="hidden" name="id" id="id" value="{{ $invoice_payment['id'] ?? false }}">
<div class="row mb-3"> <div class="row mb-3">
<div class="col-6"> <div class="col-12">
@include('components.form.datepicker', [ @include('components.form.datepicker', [
'label' => 'Date', 'label' => 'Date',
'name' => 'date', 'name' => 'date',
'value' => $invoice_payment['date'] ?? null, 'value' => $invoice_payment['date'] ?? null,
]) ])
</div> </div>
<div class="col-6"> </div>
<div class="row mb-3">
<div class="col-12">
@include('components.form.select', [ @include('components.form.select', [
'label' => 'Règlement', 'label' => 'Règlement',
'name' => 'payment_type', 'name' => 'payment_type',
@@ -17,7 +22,7 @@
</div> </div>
</div> </div>
<div class="row mb-3"> <div class="row mb-3">
<div class="col-6"> <div class="col-12">
@include('components.form.inputs.money', [ @include('components.form.inputs.money', [
'label' => 'Montant', 'label' => 'Montant',
'name' => 'amount', 'name' => 'amount',
@@ -25,3 +30,17 @@
]) ])
</div> </div>
</div> </div>
<div class="row mb-3">
<div class="col-12">
@include('components.form.input', [
'label' => 'Référence',
'name' => 'reference',
'value' => $invoice_payment['reference'] ?? null,
])
</div>
</div>
</form>
<script>
initDatepicker();
</script>

View File

@@ -6,9 +6,6 @@
@section('content') @section('content')
<x-card> <x-card>
@include('components.datatable', [ @include('Admin.Shop.InvoicePayments.list')
'route' => route('Admin.Shop.InvoicePayments.index'),
'model' => 'invoice_payments',
])
</x-card> </x-card>
@endsection @endsection

View File

@@ -4,7 +4,7 @@
<div class="col-9"> <div class="col-9">
<h5> <h5>
<a href="{{ route('Admin.Shop.Orders.edit', ['id' => $invoice['order_id']]) }}" class="btn btn-success"> <a href="{{ route('Admin.Shop.Orders.edit', ['id' => $invoice['order_id']]) }}" class="btn btn-success">
<i class="fa fa-truck"></i> <i class="fa fa-fw fa-truck"></i>
</a> </a>
Facture {{ $invoice['ref'] }} Facture {{ $invoice['ref'] }}
<span class="small"> <span class="small">
@@ -20,12 +20,11 @@
<div class="row mb-3"> <div class="row mb-3">
<div class="col-6"> <div class="col-6">
<h5> <h5>
@if ($invoice['order']['customer']['company'])
Société : {{ $invoice['order']['customer']['company'] }}<br />
@endif
{{ $invoice['order']['customer']['first_name'] }} {{ $invoice['order']['customer']['first_name'] }}
{{ $invoice['order']['customer']['last_name'] }} {{ $invoice['order']['customer']['last_name'] }}
@if ($invoice['order']['customer']['company'])
<br>
{{ $invoice['order']['customer']['company'] }}
@endif
</h5> </h5>
@if ($invoice['order']['delivery_address']) @if ($invoice['order']['delivery_address'])

View File

@@ -27,6 +27,8 @@
</table> </table>
@endif @endif
@include('load.form.datepicker')
@push('js') @push('js')
<script> <script>
$('#add_payment').click(function() { $('#add_payment').click(function() {
@@ -37,14 +39,14 @@
var url_open = "{{ route('Admin.Shop.InvoicePayments.create') }}"; var url_open = "{{ route('Admin.Shop.InvoicePayments.create') }}";
var url_save = "{{ route('Admin.Shop.InvoicePayments.store') }}"; var url_save = "{{ route('Admin.Shop.InvoicePayments.store') }}";
openModal("Ajouter un paiement", '#invoice_payment-form', url_open, url_save, openModal("Ajouter un paiement", '#invoice_payment-form', url_open, url_save,
"InvoicePaymentRefresh();"); "InvoicePaymentRefresh();", 'sm');
} }
function InvoicePaymentEdit(id) { function InvoicePaymentEdit(id) {
var url_open = "{{ route('Admin.Shop.InvoicePayments.edit') }}/" + id; var url_open = "{{ route('Admin.Shop.InvoicePayments.edit') }}/" + id;
var url_save = "{{ route('Admin.Shop.InvoicePayments.store') }}"; var url_save = "{{ route('Admin.Shop.InvoicePayments.store') }}";
openModal("Editer un paiement", '#invoice_payment-form', url_open, url_save, openModal("Editer un paiement", '#invoice_payment-form', url_open, url_save,
"InvoicePaymentRefresh();"); "InvoicePaymentRefresh();", 'sm');
} }
function InvoicePaymentRefresh() { function InvoicePaymentRefresh() {

View File

@@ -1,28 +1,31 @@
@extends('layout.index', [ @extends('layout.index', [
'title' => __('article_families.title'), 'title' => __('article_families.title'),
'subtitle' => __('article_families.create.title'), 'subtitle' => __('article_families.create.title'),
'breadcrumb' => [__('article_families.title'), __('article_families.create.title')] 'breadcrumb' => [__('article_families.title'), __('article_families.create.title')],
]) ])
@include('boilerplate::load.fileinput') @include('boilerplate::load.fileinput')
@section('content') @section('content')
{{ Form::open([
'route' => 'Admin.Shop.ArticleFamilies.store',
'id' => 'article-family-form',
'autocomplete' => 'off',
'files' => true,
]) }}
{{ Form::open(['route' => 'Admin.Shop.ArticleFamilies.store', 'id' => 'article-family-form', 'autocomplete' => 'off', 'files' => true]) }} <div class="row">
<div class="col-sm-12 mbl">
<div class="row"> <a href="{{ route('Admin.Shop.Articles.index') }}" class="btn btn-default">
<div class="col-sm-12 mbl"> {{ __('article_families.list.title') }}
<a href="{{ route("Admin.Shop.Articles.index") }}" class="btn btn-default"> </a>
{{ __('article_families.list.title') }}
</a>
<span class="btn-group pull-right"> <span class="btn-group pull-right">
@include('components.form.buttons.button-save') <x-save />
</span> </span>
</div> </div>
</div> </div>
@include('Admin.Shop.ArticleFamilies.form')
</form>
@include('Admin.Shop.ArticleFamilies.form')
</form>
@endsection @endsection

View File

@@ -13,7 +13,7 @@
<h5> <h5>
<a href="{{ route('Admin.Shop.Invoices.edit', ['id' => $order['invoice']['id']]) }}" <a href="{{ route('Admin.Shop.Invoices.edit', ['id' => $order['invoice']['id']]) }}"
class="btn btn-success"> class="btn btn-success">
<i class="fa fa-file-invoice"></i> <i class="fa fa-fw fa-file-invoice"></i>
</a> </a>
Commande : {{ $order['ref'] }} Commande : {{ $order['ref'] }}
<span class="small"> <span class="small">
@@ -29,11 +29,10 @@
<div class="row mb-3"> <div class="row mb-3">
<div class="col-6"> <div class="col-6">
<h5> <h5>
{{ $order['customer']['first_name'] }} {{ $order['customer']['last_name'] }}
@if ($order['customer']['company']) @if ($order['customer']['company'])
<br> Société : {{ $order['customer']['company'] }}<br />
{{ $order['customer']['company'] }}
@endif @endif
{{ $order['customer']['first_name'] }} {{ $order['customer']['last_name'] }}
</h5> </h5>
<h6> <h6>
@@ -49,6 +48,13 @@
</x-card> </x-card>
@endif @endif
@if ($order['comment'])
<x-card title="Commentaire" class="mt-3">
{{ $order['comment'] }}
</x-card>
@endif
</div> </div>
<div class="col-6"> <div class="col-6">
<div class="row mb-3"> <div class="row mb-3">
@@ -103,6 +109,7 @@
</div> </div>
</x-card> </x-card>
@endif @endif
</div> </div>
</div> </div>
<div class="row mb-3"> <div class="row mb-3">

View File

@@ -1,11 +1,12 @@
<x-card title="Détail de la {{ $detail_type }}"> <x-card title="Détail de la {{ $detail_type }}" classBody="p-0">
<table class="table table-bordered table-hover w-100 "> <table class="table table-bordered table-hover w-100 ">
<thead class="thead-light"> <thead class="thead-light">
<th>Nom</th> <th>Nom</th>
<th>Quantité</th> <th>Quantité</th>
<th>PU HT</th> <th>PU HT</th>
<th>Total HT</th>
<th>TVA</th> <th>TVA</th>
<th>PU TTC</th> <th>Montant TVA</th>
<th>Total TTC</th> <th>Total TTC</th>
</thead> </thead>
<tbody> <tbody>
@@ -14,8 +15,9 @@
<td>{{ $detail['name'] }}</td> <td>{{ $detail['name'] }}</td>
<td class="text-right">{{ $detail['quantity'] }}</td> <td class="text-right">{{ $detail['quantity'] }}</td>
<td class="text-right">{{ $detail['price'] }}</td> <td class="text-right">{{ $detail['price'] }}</td>
<td class="text-right">{{ $detail['tax'] }}</td> <td class="text-right">{{ $detail['total'] }}</td>
<td class="text-right">{{ $detail['price_taxed'] }}</td> <td class="text-right">{{ $detail['vat'] }}</td>
<td class="text-right">{{ $detail['total_tax'] }}</td>
<td class="text-right">{{ $detail['total_taxed'] }}</td> <td class="text-right">{{ $detail['total_taxed'] }}</td>
</tr> </tr>
@endforeach @endforeach
@@ -25,8 +27,11 @@
<td style="font-size: 1.2em; font-weight: bold;">Total</td> <td style="font-size: 1.2em; font-weight: bold;">Total</td>
<td></td> <td></td>
<td></td> <td></td>
<td style="font-size: 1.2em; font-weight: bold;" class="text-right">
{{ $order['total'] }}
</td>
<td></td> <td></td>
<td></td> <td class="text-right">{{ $order['taxes'] }}</td>
<td style="font-size: 1.2em; font-weight: bold;" class="text-right"> <td style="font-size: 1.2em; font-weight: bold;" class="text-right">
{{ $order['total_taxed'] }} {{ $order['total_taxed'] }}
</td> </td>
@@ -38,6 +43,7 @@
<td></td> <td></td>
<td></td> <td></td>
<td></td> <td></td>
<td></td>
<td style="font-size: 1.1em; font-weight: bold;" class="text-right"> <td style="font-size: 1.1em; font-weight: bold;" class="text-right">
{{ $order['shipping'] }} {{ $order['shipping'] }}
</td> </td>
@@ -46,8 +52,9 @@
<td style="font-size: 1.4em; font-weight: bold;">Total à payer</td> <td style="font-size: 1.4em; font-weight: bold;">Total à payer</td>
<td></td> <td></td>
<td></td> <td></td>
<td class="text-right">{{ $order['taxes'] }}</td> <td class="text-right">{{ $order['total'] }}</td>
<td></td> <td></td>
<td class="text-right">{{ $order['taxes'] }}</td>
<td style="font-size: 1.4em; font-weight: bold;" class="text-right"> <td style="font-size: 1.4em; font-weight: bold;" class="text-right">
{{ $order['total_shipped'] }} {{ $order['total_shipped'] }}
</td> </td>