From efbb3d091f8fb6676e84603a6392da8068b71e0c Mon Sep 17 00:00:00 2001 From: Deon George Date: Sat, 10 Aug 2024 10:14:47 +1000 Subject: [PATCH] Separated Checkout and Payment controllers, updates to checkout and payments --- app/Http/Controllers/AdminController.php | 110 +------- app/Http/Controllers/CheckoutController.php | 49 ++-- app/Http/Controllers/InvoiceController.php | 18 +- app/Http/Controllers/PaymentController.php | 73 +++++ app/Http/Controllers/SearchController.php | 2 +- app/Http/Requests/CheckoutAddEdit.php | 9 +- app/Http/Requests/PaymentAddEdit.php | 62 +++++ app/Models/Checkout.php | 4 +- app/Models/Invoice.php | 5 +- app/Models/Payment.php | 7 +- public/css/fixes.css | 11 +- .../adminlte/a/payment/addedit.blade.php | 254 ------------------ .../adminlte/checkout/choose.blade.php | 52 ++++ .../backend/adminlte/checkout/view.blade.php | 37 +++ .../adminlte/checkout/widget/detail.blade.php | 37 +++ .../backend/adminlte/payment/home.blade.php | 73 ----- .../{a => }/payment/unapplied.blade.php | 21 +- .../backend/adminlte/payment/view.blade.php | 167 ++++++++++-- .../adminlte/payment/widget/detail.blade.php | 70 ----- .../widget}/invoices.blade.php | 11 +- .../layouts/partials/sidebarmenu.blade.php | 10 +- routes/api.php | 7 - routes/web.php | 26 +- 23 files changed, 512 insertions(+), 603 deletions(-) create mode 100644 app/Http/Controllers/PaymentController.php create mode 100644 app/Http/Requests/PaymentAddEdit.php delete mode 100644 resources/views/theme/backend/adminlte/a/payment/addedit.blade.php create mode 100644 resources/views/theme/backend/adminlte/checkout/choose.blade.php create mode 100644 resources/views/theme/backend/adminlte/checkout/view.blade.php create mode 100644 resources/views/theme/backend/adminlte/checkout/widget/detail.blade.php delete mode 100644 resources/views/theme/backend/adminlte/payment/home.blade.php rename resources/views/theme/backend/adminlte/{a => }/payment/unapplied.blade.php (77%) delete mode 100644 resources/views/theme/backend/adminlte/payment/widget/detail.blade.php rename resources/views/theme/backend/adminlte/{a/payment/widgets => payment/widget}/invoices.blade.php (68%) diff --git a/app/Http/Controllers/AdminController.php b/app/Http/Controllers/AdminController.php index 68348ef..7bf3271 100644 --- a/app/Http/Controllers/AdminController.php +++ b/app/Http/Controllers/AdminController.php @@ -3,15 +3,9 @@ namespace App\Http\Controllers; use Illuminate\Http\RedirectResponse; -use Illuminate\Http\Request; use App\Http\Requests\SiteEdit; -use App\Models\{Account, - Invoice, - Payment, - PaymentItem, - Service, - SiteDetail}; +use App\Models\SiteDetail; /** * The AdminController governs all routes that are prefixed with 'a/'. @@ -20,108 +14,6 @@ use App\Models\{Account, */ class AdminController extends Controller { - /** - * Record payments on an account. - * - * @param Request $request - * @param Payment $o - * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View|\Illuminate\Http\RedirectResponse - */ - // @todo Move to reseller - public function pay_addedit(Request $request,Payment $o) - { - if ($request->post()) { - - $validation = $request->validate([ - 'account_id' => 'required|exists:accounts,id', - 'paid_at' => 'required|date', - 'checkout_id' => 'required|exists:checkouts,id', - 'total_amt' => 'required|numeric|min:0.01', - 'fees_amt' => 'nullable|numeric|lt:total_amt', - 'source_id' => 'nullable|exists:accounts,id', - 'pending' => 'nullable|boolean', - 'notes' => 'nullable|string', - 'ip' => 'nullable|ip', - 'invoices' => ['required','array',function ($attribute,$value,$fail) use ($request) { - if (collect($value)->sum('id') > $request->post('total_amt')) - $fail('Allocation is greater than payment total.'); - }], - 'invoices.*.id' => ['required',function ($attribute,$value,$fail) { - if (! Invoice::exists(str_replace(str_replace($attribute,'invoice\.','',),'.id',''))) - $fail('Invoice doesnt exist in DB'); - }], - ]); - - if (! $o->exists) { - $o->site_id = config('site')->site_id; - $o->active = TRUE; - } - - $o->forceFill($request->only(['account_id','paid_at','checkout_id','total_amt','fees_amt','source_id','pending','notes','ip'])); - $o->save(); - - foreach ($validation['invoices'] as $id => $amount) { - // See if we already have a payment item that we need to update - $items = $o->items->filter(function($item) use ($id) { return $item->invoice_id == $id; }); - - if ($items->count() == 1) { - $oo = $items->pop(); - if ($amount['id'] == 0) { - $oo->delete(); - continue; - } - - } else { - $oo = new PaymentItem; - $oo->invoice_id = $id; - } - - $oo->amount = ($oo->invoice->due >= 0) && ($oo->invoice->due-$amount['id'] >= 0) ? $amount['id'] : 0; - - // If the amount is empty, ignore it. - if (! $oo->amount) - continue; - - $oo->site_id = config('site')->site_id; - $oo->active = TRUE; - $o->items()->save($oo); - } - - return redirect() - ->back() - ->with('success','Payment recorded: '.$o->id); - } - - return view('theme.backend.adminlte.a.payment.addedit') - ->with('o',$o); - } - - /** - * List unapplied payments - * - * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View - */ - // @todo Move to reseller - public function pay_unapplied() - { - return view('theme.backend.adminlte.a.payment.unapplied'); - } - - /** - * Show a list of invoices to apply payments to - * - * @param Request $request - * @param Account $o - * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View - */ - // @todo Move to reseller - public function pay_invoices(Request $request,Account $o) - { - return view('theme.backend.adminlte.a.payment.widgets.invoices') - ->with('pid',$request->pid) - ->with('o',$o); - } - /** * Site setup * diff --git a/app/Http/Controllers/CheckoutController.php b/app/Http/Controllers/CheckoutController.php index bcc4248..76c0097 100644 --- a/app/Http/Controllers/CheckoutController.php +++ b/app/Http/Controllers/CheckoutController.php @@ -2,8 +2,8 @@ namespace App\Http\Controllers; +use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; -use Illuminate\View\View; use App\Http\Requests\CheckoutAddEdit; use App\Models\{Checkout,Invoice}; @@ -11,31 +11,35 @@ use App\Models\{Checkout,Invoice}; class CheckoutController extends Controller { /** - * Update a suppliers details + * Update a checkout details * * @param CheckoutAddEdit $request * @param Checkout $o - * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View|\Illuminate\Http\RedirectResponse + * @return RedirectResponse */ - public function addedit(CheckoutAddEdit $request,Checkout $o) + public function addedit(CheckoutAddEdit $request,Checkout $o): RedirectResponse { - $this->middleware(['auth','wholesaler']); - - foreach ($request->except(['_token','active','submit']) as $key => $item) + foreach ($request->validated() as $key => $item) $o->{$key} = $item; - $o->active = (bool)$request->active; + $o->active = (bool)$request->validated('active',FALSE); try { $o->save(); } catch (\Exception $e) { - return redirect()->back()->withErrors($e->getMessage())->withInput(); + return redirect() + ->back() + ->withErrors($e->getMessage())->withInput(); } - return redirect() - ->back() - ->with('success','Payment saved'); + return $o->wasRecentlyCreated + ? redirect() + ->to('a/checkout/'.$o->id) + ->with('success','Checkout added') + : redirect() + ->back() + ->with('success','Checkout saved'); } public function cart_invoice(Request $request,Invoice $o=NULL) @@ -57,29 +61,8 @@ class CheckoutController extends Controller return $o->fee($request->post('total',0)); } - /** - * Render a specific invoice for the user - * - * @return View - */ - public function home(): View - { - return view('theme.backend.adminlte.payment.home'); - } - public function pay(Request $request,Checkout $o) { return redirect('pay/paypal/authorise'); } - - /** - * View details on a specific payment method - * - * @param Checkout $o - * @return View - */ - public function view(Checkout $o): View - { - return view('theme.backend.adminlte.payment.view',['o'=>$o]); - } } \ No newline at end of file diff --git a/app/Http/Controllers/InvoiceController.php b/app/Http/Controllers/InvoiceController.php index c578c82..ba2ead7 100644 --- a/app/Http/Controllers/InvoiceController.php +++ b/app/Http/Controllers/InvoiceController.php @@ -4,10 +4,11 @@ namespace App\Http\Controllers; use Clarkeash\Doorman\Exceptions\{ExpiredInviteCode,InvalidInviteCode,NotYourInviteCode}; use Clarkeash\Doorman\Facades\Doorman; +use Illuminate\Http\Request; use Illuminate\View\View; use Barryvdh\Snappy\Facades\SnappyPdf as PDF; -use App\Models\Invoice; +use App\Models\{Account,Invoice}; /** * Class InvoiceController @@ -19,6 +20,21 @@ use App\Models\Invoice; */ class InvoiceController extends Controller { + /** + * Show a list of invoices to apply payments to + * + * @param Request $request + * @return \Illuminate\Contracts\View\View + */ + public function api_account_invoices(Request $request): \Illuminate\Contracts\View\View + { + session()->flashInput($request->post('old',[])); + + return view('theme.backend.adminlte.payment.widget.invoices') + ->with('pid',$request->post('pid')) + ->with('o',Account::findOrFail($request->post('aid'))); + } + /** * Return the invoice in PDF format, ready to download * diff --git a/app/Http/Controllers/PaymentController.php b/app/Http/Controllers/PaymentController.php new file mode 100644 index 0000000..d002f70 --- /dev/null +++ b/app/Http/Controllers/PaymentController.php @@ -0,0 +1,73 @@ +validated(),'invoices') as $k=>$v) + $o->{$k} = $v; + + foreach ($request->validated('invoices',[]) as $id => $amount) { + // See if we already have a payment item that we need to update + $items = $o->items + ->filter(fn($item)=>$item->invoice_id == $id); + + if ($items->count() === 1) { + $oo = $items->pop(); + + if ($amount == 0) { + $oo->delete(); + continue; + } + + } else { + $oo = new PaymentItem; + $oo->invoice_id = $id; + } + + $oo->amount = ($oo->invoice->due >= 0) && ($oo->invoice->due-$amount >= 0) + ? $amount + : 0; + + // If the amount is empty, ignore it. + if (! $oo->amount) + continue; + + $oo->site_id = config('site')->site_id; + $oo->active = TRUE; + $o->items->push($oo); + } + + try { + $o->pushNew(); + + } catch (\Exception $e) { + return redirect() + ->back() + ->withErrors($e->getMessage())->withInput(); + } + + return $o->wasRecentlyCreated + ? redirect() + ->to('r/payment/'.$o->id) + ->with('success','Payment added') + : redirect() + ->back() + ->with('success','Payment saved'); + } +} \ No newline at end of file diff --git a/app/Http/Controllers/SearchController.php b/app/Http/Controllers/SearchController.php index 13b06e5..7d584b2 100644 --- a/app/Http/Controllers/SearchController.php +++ b/app/Http/Controllers/SearchController.php @@ -90,7 +90,7 @@ class SearchController extends Controller ->whereIN('account_id',$account_ids) ->limit(10)->get() as $o) { - $result->push(['name'=>sprintf('%s: %s $%s',$o->lid,$o->account->name,number_format($o->total,2)),'value'=>'/a/payment/addedit/'.$o->id,'category'=>'Payments']); + $result->push(['name'=>sprintf('%s: %s $%s',$o->lid,$o->account->name,number_format($o->total,2)),'value'=>'/r/payment/addedit/'.$o->id,'category'=>'Payments']); } } diff --git a/app/Http/Requests/CheckoutAddEdit.php b/app/Http/Requests/CheckoutAddEdit.php index 2c14bdb..8076a3c 100644 --- a/app/Http/Requests/CheckoutAddEdit.php +++ b/app/Http/Requests/CheckoutAddEdit.php @@ -4,6 +4,7 @@ namespace App\Http\Requests; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Support\Facades\Auth; +use Illuminate\Validation\Rule; /** * Editing Suppliers @@ -28,7 +29,13 @@ class CheckoutAddEdit extends FormRequest public function rules() { return [ - 'name' => 'required|string|min:2|max:255', + 'name' => [ + 'required', + 'string', + 'min:2', + 'max:255', + Rule::unique('checkouts','name')->ignore($this->route('o')?->id), + ], 'active' => 'sometimes|accepted', 'description' => 'nullable|string|min:2|max:255', ]; diff --git a/app/Http/Requests/PaymentAddEdit.php b/app/Http/Requests/PaymentAddEdit.php new file mode 100644 index 0000000..4c8d3ee --- /dev/null +++ b/app/Http/Requests/PaymentAddEdit.php @@ -0,0 +1,62 @@ +isWholesaler(); + } + + /** + * Get the validation rules that apply to the request. + * + * @return array + */ + public function rules() + { + return [ + 'account_id' => 'required|exists:accounts,id', + 'paid_at' => 'required|date', + 'checkout_id' => 'required|exists:checkouts,id', + 'total_amt' => 'required|numeric|min:0.01', + 'fees_amt' => 'nullable|numeric|lt:total_amt', + 'source_id' => 'nullable|exists:accounts,id', + 'pending' => 'nullable|boolean', + 'notes' => 'nullable|string', + 'ip' => 'nullable|ip', + 'invoices' => [ + 'nullable', + 'array', + function($attribute,$value,$fail) { + if (($x=collect($value)->sum()) > request()->post('total_amt')) + $fail(sprintf('Allocation %3.2f is greater than payment total %3.2f.',$x,request()->post('total_amt'))); + } + ], + 'invoices.*' => [ + 'nullable', + function($attribute,$value,$fail) { + if (! ($x=Invoice::where('id',$xx=str_replace('invoices.','',$attribute))->first())) + $fail(sprintf('Invoice [%d] doesnt exist in DB',$xx)); + // @todo The due amount may be influenced by this payment (ie: payment edit) + elseif($x->due < $value) + $fail(sprintf('Invoice [%d] is over allocated by %3.2f',$x->id,$value-$x->due)); + } + ], + ]; + } +} \ No newline at end of file diff --git a/app/Models/Checkout.php b/app/Models/Checkout.php index 73c391e..3c78050 100644 --- a/app/Models/Checkout.php +++ b/app/Models/Checkout.php @@ -6,9 +6,11 @@ use Illuminate\Database\Eloquent\Collection; use Illuminate\Database\Eloquent\Model; use Leenooks\Traits\ScopeActive; +use App\Traits\SiteID; + class Checkout extends Model { - use ScopeActive; + use ScopeActive,SiteID; protected $casts = [ 'plugin_data'=>'json', diff --git a/app/Models/Invoice.php b/app/Models/Invoice.php index de3e439..8774eb4 100644 --- a/app/Models/Invoice.php +++ b/app/Models/Invoice.php @@ -300,8 +300,7 @@ class Invoice extends Model implements IDs /** * @param \Leenooks\Carbon $start Start Date * @param Carbon $end End Date - * @param int $interval Period End Date - * @param bool $strict + * @param Collection $period * @return float * @throws \Exception */ @@ -373,7 +372,7 @@ class Invoice extends Model implements IDs public function payments() { return $this->hasManyThrough(Payment::class,PaymentItem::class,NULL,'id',NULL,'payment_id') - ->where('active',TRUE); + ->where('payments.active',TRUE); } /** diff --git a/app/Models/Payment.php b/app/Models/Payment.php index c151c7f..92bb404 100644 --- a/app/Models/Payment.php +++ b/app/Models/Payment.php @@ -7,8 +7,7 @@ use Illuminate\Support\Facades\DB; use Leenooks\Traits\ScopeActive; use App\Interfaces\IDs; -use App\Traits\ProviderRef; -use App\Traits\PushNew; +use App\Traits\{ProviderRef,PushNew,SiteID}; /** * Class Payment @@ -25,7 +24,7 @@ use App\Traits\PushNew; */ class Payment extends Model implements IDs { - use PushNew,ScopeActive,ProviderRef; + use PushNew,ScopeActive,ProviderRef,SiteID; protected $casts = [ 'paid_at'=>'datetime:Y-m-d', @@ -106,7 +105,7 @@ class Payment extends Model implements IDs ->select(['payments.id','paid_at','account_id','checkout_id','total_amt',DB::raw("SUM(ABS(amount)) as allocated")]) ->leftJoin('payment_items',['payment_items.payment_id'=>'payments.id']) ->groupBy(['payments.id','paid_at','total_amt','account_id','checkout_id']) - ->having(DB::raw('ROUND(total_amt-IFNULL(allocated,0),2)'),'>',self::threshold); + ->having(DB::raw('ROUND(CAST(total_amt-COALESCE(SUM(ABS(amount)),0) AS NUMERIC),2)'),'>',self::threshold); } /* ATTRIBUTES */ diff --git a/public/css/fixes.css b/public/css/fixes.css index 1698488..b4788e6 100644 --- a/public/css/fixes.css +++ b/public/css/fixes.css @@ -84,8 +84,17 @@ span.select2-selection.select2-selection--single > span.select2-selection__rende width: 100%; } -/* Render the invalid red when a select container fails validation */ +/* Render the invalid red when a select container fails vlidation */ .is-invalid + .select2-container--default .select2-selection--single, .is-invalid + .select2-container--default .select2-selection--multiple { border: 1px solid #dc3545; +} + +/* When we have a hr after h3, show the line directly under the h3 */ +h3:has(+hr) { + margin-bottom: 0; +} +h3 + hr { + margin-top: 0; + margin-bottom: 2em; } \ No newline at end of file diff --git a/resources/views/theme/backend/adminlte/a/payment/addedit.blade.php b/resources/views/theme/backend/adminlte/a/payment/addedit.blade.php deleted file mode 100644 index 714651f..0000000 --- a/resources/views/theme/backend/adminlte/a/payment/addedit.blade.php +++ /dev/null @@ -1,254 +0,0 @@ -@extends('adminlte::layouts.app') - -@section('htmlheader_title') - Payment -@endsection -@section('page_title') - Payment -@endsection - -@section('contentheader_title') - Record Payment -@endsection -@section('contentheader_description') -@endsection - -@section('main-content') -
-
-
-
-

Record Payment

- @if(session()->has('success')) - {{ session()->get('success') }} - @endif -
- -
-
- @csrf - -
- -
-
- -
-
- -
- - - @error('paid_at') - {{ $message }} - @else - Payment Date is required. - @enderror - -
- Date Payment Received. -
-
- - -
-
- -
-
- -
- - - @error('total_amt') - {{ $message }} - @else - Payment Amount is required. - @enderror - -
- Amount Received. -
-
-
- -
- -
-
- -
-
- -
- - - @error('checkout_id') - {{ $message }} - @else - Payment Method is required. - @enderror - -
- Payment Method. -
-
- - -
-
- -
-
- -
- - - @error('fees_amt') - {{ $message }} - @else - Total Fees is required. - @enderror - -
- Amount Received. -
-
-
- -
- -
-
- -
-
- -
- - - - - @error('account_id') - {{ $message }} - @else - Account is required. - @enderror - -
- Account to add payment to. - -
-
- - -
- -
-
- -
- -
-
-
- -
-
-
- @error('invoices') - - {{ $message }} - - @enderror -
-
- -
-
- Cancel - @can('wholesaler') - - @endcan -
-
-
-
-
-
-
-@endsection - -@section('page-scripts') - @css(select2) - @js(select2,autofocus) - - -@append diff --git a/resources/views/theme/backend/adminlte/checkout/choose.blade.php b/resources/views/theme/backend/adminlte/checkout/choose.blade.php new file mode 100644 index 0000000..f4afba3 --- /dev/null +++ b/resources/views/theme/backend/adminlte/checkout/choose.blade.php @@ -0,0 +1,52 @@ +@use(App\Models\Checkout) + +@extends('adminlte::layouts.app') + +@section('htmlheader_title') + Payment +@endsection +@section('page_title') + Payment +@endsection + +@section('contentheader_title') + Payment +@endsection +@section('contentheader_description') +@endsection + +@section('main-content') +
+
+
+
+

Payment Configuration

+
+ +
+
+
+ +
+
+
+
+
+
+@endsection + +@pa(select2,autofocus) + +@section('page-scripts') + +@append \ No newline at end of file diff --git a/resources/views/theme/backend/adminlte/checkout/view.blade.php b/resources/views/theme/backend/adminlte/checkout/view.blade.php new file mode 100644 index 0000000..02cc4e1 --- /dev/null +++ b/resources/views/theme/backend/adminlte/checkout/view.blade.php @@ -0,0 +1,37 @@ + +@extends('adminlte::layouts.app') + +@section('htmlheader_title') + {{ $co->name ?? 'New Checkout' }} +@endsection +@section('page_title') + {{ $co->name ?? 'New Checkout' }} +@endsection + +@section('contentheader_title') + {{ $co->name ?? 'New Checkout' }} +@endsection +@section('contentheader_description') +@endsection + +@section('main-content') +
+
+
+
+ +
+ +
+
+
+ @include('theme.backend.adminlte.checkout.widget.detail',['o'=>$co ?? NULL]) +
+
+
+
+
+
+@endsection \ No newline at end of file diff --git a/resources/views/theme/backend/adminlte/checkout/widget/detail.blade.php b/resources/views/theme/backend/adminlte/checkout/widget/detail.blade.php new file mode 100644 index 0000000..68368b0 --- /dev/null +++ b/resources/views/theme/backend/adminlte/checkout/widget/detail.blade.php @@ -0,0 +1,37 @@ + +
+
+

Checkout Details

+
+
+ @csrf + +
+ +
+ +
+ + +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ + @if($o?->exists)Update @else Add @endif +
+
+
+
+
\ No newline at end of file diff --git a/resources/views/theme/backend/adminlte/payment/home.blade.php b/resources/views/theme/backend/adminlte/payment/home.blade.php deleted file mode 100644 index 4b55421..0000000 --- a/resources/views/theme/backend/adminlte/payment/home.blade.php +++ /dev/null @@ -1,73 +0,0 @@ -@extends('adminlte::layouts.app') - -@section('htmlheader_title') - Payment -@endsection -@section('page_title') - Payment -@endsection - -@section('contentheader_title') - Payment -@endsection -@section('contentheader_description') -@endsection - -@section('main-content') -
-
-
-
-

Payment Configuration

-
- -
-
- @csrf - -
-
-
- - - - @error('name') - {{ $message }} - @else - Payment Name is required. - @enderror - - Payment Name -
-
-
-
-
-
-
-
-@endsection - -@section('page-scripts') - @css(select2) - @js(select2,autofocus) - - -@endsection \ No newline at end of file diff --git a/resources/views/theme/backend/adminlte/a/payment/unapplied.blade.php b/resources/views/theme/backend/adminlte/payment/unapplied.blade.php similarity index 77% rename from resources/views/theme/backend/adminlte/a/payment/unapplied.blade.php rename to resources/views/theme/backend/adminlte/payment/unapplied.blade.php index 7821430..f736fcc 100644 --- a/resources/views/theme/backend/adminlte/a/payment/unapplied.blade.php +++ b/resources/views/theme/backend/adminlte/payment/unapplied.blade.php @@ -1,3 +1,5 @@ +@use(App\Models\Payment) + @extends('adminlte::layouts.app') @section('htmlheader_title') @@ -15,7 +17,7 @@ @section('main-content')
-
+
@@ -32,10 +34,10 @@ - @foreach(\App\Models\Payment::active()->unapplied()->with(['account.user','checkout','items'])->get() as $o) - @if (! $o->balance) @continue @endif + @foreach(Payment::active()->unapplied()->with(['account.user','checkout','items'])->get() as $o) + @continue(! $o->balance) - + @@ -52,14 +54,17 @@ @endsection -@section('page-scripts') - @css(datatables,bootstrap4) - @js(datatables,bootstrap4) +@pa(datatables,rowgroup|conditionalpaging) +@section('page-scripts') diff --git a/resources/views/theme/backend/adminlte/payment/view.blade.php b/resources/views/theme/backend/adminlte/payment/view.blade.php index d76d14e..62e444e 100644 --- a/resources/views/theme/backend/adminlte/payment/view.blade.php +++ b/resources/views/theme/backend/adminlte/payment/view.blade.php @@ -1,38 +1,167 @@ - + +@use(Carbon\Carbon) +@use(App\Models\Account) +@use(App\Models\Checkout) + @extends('adminlte::layouts.app') @section('htmlheader_title') - {{ $o->name ?: 'New Payment' }} + Payment @endsection @section('page_title') - {{ $o->name ?: 'New Payment' }} + Payment @endsection @section('contentheader_title') - {{ $o->name ?: 'New Payment' }} + Record Payment @endsection @section('contentheader_description') - @include('adminlte::widget.status') @endsection @section('main-content') -
-
-
-
- -
+
+
+
+ @csrf -
-
-
- @include('theme.backend.adminlte.payment.widget.detail') + +
+
+
+
+ + + +
+
+ +
+
+ + +
+
+ + +
+
+ +
+
+
+ +
+
+
+ + +
+
+ +
+
+ + +
+
+ +
+
+ + +
-
+ +
+
+
+ @error('invoices') + + {{ $message }} + + @enderror +
+
+ +
+ +
+ + @if($po?->exists ?? FALSE)Update @else Add @endif +
+
+
-@endsection \ No newline at end of file + + +@endsection + +@section('page-scripts') + +@append \ No newline at end of file diff --git a/resources/views/theme/backend/adminlte/payment/widget/detail.blade.php b/resources/views/theme/backend/adminlte/payment/widget/detail.blade.php deleted file mode 100644 index cd50c98..0000000 --- a/resources/views/theme/backend/adminlte/payment/widget/detail.blade.php +++ /dev/null @@ -1,70 +0,0 @@ - -
-
-

Checkout Details

-
- @if(session()->has('success')) - {{ session()->get('success') }} - @endif - -
- @csrf - -
-
-
- -
-
- - - - @error('name') - {{ $message }} - @else - Payment Name required. - @enderror - -
-
- - -
-
-
- active) ? 'checked' : '' }}> - -
-
-
-
-
-
- -
- -
-
- - - - @error('description') - {{ $message }} - @enderror - -
-
-
- -
- -
- Cancel - @can('wholesaler') - - @endcan -
-
- -
-
\ No newline at end of file diff --git a/resources/views/theme/backend/adminlte/a/payment/widgets/invoices.blade.php b/resources/views/theme/backend/adminlte/payment/widget/invoices.blade.php similarity index 68% rename from resources/views/theme/backend/adminlte/a/payment/widgets/invoices.blade.php rename to resources/views/theme/backend/adminlte/payment/widget/invoices.blade.php index 9fccc01..954a700 100644 --- a/resources/views/theme/backend/adminlte/a/payment/widgets/invoices.blade.php +++ b/resources/views/theme/backend/adminlte/payment/widget/invoices.blade.php @@ -1,9 +1,10 @@ -
- + +
+ @if(($x=$o->invoices() - ->where('active',TRUE) + ->active() ->orderBy('due_at') - ->with(['items.taxes','payment_items.payment','account']) + ->with(['items.taxes','payments','account']) ->get() ->filter(function($item) use ($pid) { return $item->due > 0 || $item->payments->search(function($item) use ($pid) { return $item->id == $pid; }) !== FALSE; }))->count())
{{ $o->id }}{{ $o->id }} {{ $o->paid_at->format('Y-m-d') }} {{ $o->account->name }} {{ $o->checkout->name }}
@@ -27,7 +28,7 @@ @endforeach diff --git a/resources/views/vendor/adminlte/layouts/partials/sidebarmenu.blade.php b/resources/views/vendor/adminlte/layouts/partials/sidebarmenu.blade.php index 9432209..0f427a0 100644 --- a/resources/views/vendor/adminlte/layouts/partials/sidebarmenu.blade.php +++ b/resources/views/vendor/adminlte/layouts/partials/sidebarmenu.blade.php @@ -24,21 +24,21 @@ @can('wholesaler') -
  • $x=preg_match('#^a/payment/#',$path),'menu-closed'=>! $x])> - preg_match('#^a/payment/#',$path)])> +
  • $x=preg_match('#^r/payment/#',$path),'menu-closed'=>! $x])> + preg_match('#^r/payment/#',$path)])>

    Payments

  • {{ number_format($io->total,2) }} {{ number_format($io->due,2) }} - +