Separated Checkout and Payment controllers, updates to checkout and payments
This commit is contained in:
@@ -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')
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card card-dark">
|
||||
<div class="card-header">
|
||||
<h1 class="card-title">Payment Configuration</h1>
|
||||
</div>
|
||||
|
||||
<div class="card-body">
|
||||
<form class="g-0 needs-validation" method="POST" enctype="multipart/form-data" role="form">
|
||||
@csrf
|
||||
|
||||
<div class="row">
|
||||
<div class="col-4">
|
||||
<div class="form-group has-validation">
|
||||
<label for="name">Payment Name</label>
|
||||
<select class="form-control form-control-border" id="name" name="checkout_id">
|
||||
<option value=""></option>
|
||||
<option value="">Add New</option>
|
||||
@foreach(\App\Models\Checkout::orderBy('active','DESC')->orderBy('name')->get()->groupBy('active') as $o)
|
||||
<optgroup label="{{ $o->first()->active ? 'Active' : 'Not Active' }}">
|
||||
@foreach($o as $oo)
|
||||
<option value="{{ $oo->id }}">{{ $oo->name }}</option>
|
||||
@endforeach
|
||||
</optgroup>
|
||||
@endforeach
|
||||
</select>
|
||||
<span class="invalid-feedback" role="alert">
|
||||
@error('name')
|
||||
{{ $message }}
|
||||
@else
|
||||
Payment Name is required.
|
||||
@enderror
|
||||
</span>
|
||||
<span class="input-helper">Payment Name</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@section('page-scripts')
|
||||
@css(select2)
|
||||
@js(select2,autofocus)
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
$('#name').select2()
|
||||
.on('change',function(item) {
|
||||
window.location.href = '{{ url('a/checkout') }}'+(item.target.value ? '/'+item.target.value : '');
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@endsection
|
@@ -0,0 +1,71 @@
|
||||
@use(App\Models\Payment)
|
||||
|
||||
@extends('adminlte::layouts.app')
|
||||
|
||||
@section('htmlheader_title')
|
||||
Unapplied Payments
|
||||
@endsection
|
||||
@section('page_title')
|
||||
Unapplied
|
||||
@endsection
|
||||
|
||||
@section('contentheader_title')
|
||||
Unapplied Payments
|
||||
@endsection
|
||||
@section('contentheader_description')
|
||||
@endsection
|
||||
|
||||
@section('main-content')
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<table class="table table-striped table-hover" id="unapplied_payments">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Date Paid</th>
|
||||
<th>Account</th>
|
||||
<th>Method</th>
|
||||
<th class="text-right">Total</th>
|
||||
<th class="text-right">Balance</th>
|
||||
<th>Invoices</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
@foreach(Payment::active()->unapplied()->with(['account.user','checkout','items'])->get() as $o)
|
||||
@continue(! $o->balance)
|
||||
<tr>
|
||||
<td><a href="{{ url('r/payment',$o->id) }}">{{ $o->id }}</td>
|
||||
<td>{{ $o->paid_at->format('Y-m-d') }}</td>
|
||||
<td>{{ $o->account->name }}</td>
|
||||
<td>{{ $o->checkout->name }}</td>
|
||||
<td class="text-right">{{ number_format($o->total_amt,2) }}</td>
|
||||
<td class="text-right">{{ number_format($o->balance,2) }}</td>
|
||||
<td>{!! $o->items->pluck('invoice_id')->map(function($item) { return sprintf('<a href="%s">%d</a>',url('u/invoice',$item),$item); })->join(', ') !!}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@pa(datatables,rowgroup|conditionalpaging)
|
||||
|
||||
@section('page-scripts')
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
$('#unapplied_payments').DataTable({
|
||||
order: [1,'desc'],
|
||||
rowGroup: {
|
||||
dataSrc: 2,
|
||||
},
|
||||
conditionalPaging: true,
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@append
|
@@ -1,38 +1,167 @@
|
||||
<!-- $o = Checkout::class -->
|
||||
<!-- po=Payment::class -->
|
||||
@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')
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<div class="card-header bg-dark d-flex p-0">
|
||||
<ul class="nav nav-pills w-100 p-2">
|
||||
<li class="nav-item"><a class="nav-link active" href="#details" data-toggle="tab">Detail</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="card card-dark">
|
||||
<div class="card-body">
|
||||
<form method="POST" action="{{ url('r/payment',$po?->id ?? '') }}">
|
||||
@csrf
|
||||
|
||||
<div class="card-body">
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane fade active show" id="details" role="tabpanel">
|
||||
@include('theme.backend.adminlte.payment.widget.detail')
|
||||
<x-leenooks::button.success class="float-right" row="true"/>
|
||||
<div class="row">
|
||||
<div class="col-12 col-sm-6 col-lg-3">
|
||||
<div class="row">
|
||||
<div class="col-12 col-md-9 col-lg-12">
|
||||
<!-- Account -->
|
||||
<!-- @todo Only show active accounts or accounts with outstanding invoices -->
|
||||
<x-leenooks::form.select name="account_id" icon="fa-user" label="Account" feedback="Sweep Type is required" helper="Account to add payment to." :options="Account::active()->with(['user'])->get()->sortBy('name')->map(fn($item,$key)=>['id'=>$item->id,'value'=>$item->name])" :value="$po?->account_id ?? ''"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12 col-md-9 col-lg-12">
|
||||
<!-- Received -->
|
||||
<x-leenooks::form.date name="paid_at" icon="fa-calendar" label="Date Received" feedback="Payment Date is required" helper="Date payment received" :value="($po?->paid_at ?? Carbon::now())->format('Y-m-d')"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- METHOD -->
|
||||
<div class="row">
|
||||
<div class="col-12 col-md-9 col-lg-12">
|
||||
<x-leenooks::form.select name="checkout_id" icon="fa-dollar-sign" label="Payment Method" :options="Checkout::orderBy('name')->get()->map(fn($item,$key)=>['id'=>$item->id,'value'=>$item->name])" :value="$po?->checkout_id ?? ''"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-12 col-sm-6 col-log-3">
|
||||
<div class="row">
|
||||
<div class="col-12 col-md-6">
|
||||
<!-- Amount -->
|
||||
<x-leenooks::form.text class="text-right" id="total_amt" name="total_amt" icon="fa-dollar-sign" label="Amount" helper="Amount received" :value="$po?->total_amt ?? 0"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12 col-md-6">
|
||||
<!-- Payment Fee -->
|
||||
<x-leenooks::form.text class="text-right" id="fees_amt" name="fees_amt" icon="fa-dollar-sign" label="Fee" helper="Payment fees" :value="$po?->fees_amt ?? ''"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12 col-md-6">
|
||||
<!-- Balance -->
|
||||
<x-leenooks::form.text class="text-right" id="balance" name="balance" icon="fa-dollar-sign" label="Balance" helper="Payment unallocated" :value="$po?->total ?? 0" disabled/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mt-3 mb-3">
|
||||
<div class="col-12">
|
||||
<div id="invoices"></div>
|
||||
@error('invoices')
|
||||
<span class="invalid-feedback d-block mt-2 mb-2">
|
||||
{{ $message }}
|
||||
</span>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<!-- Buttons -->
|
||||
<div class="col">
|
||||
<x-leenooks::button.cancel/>
|
||||
<x-leenooks::button.submit class="float-right">@if($po?->exists ?? FALSE)Update @else Add @endif</x-leenooks::button.submit>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
<x-leenooks::errors/>
|
||||
@endsection
|
||||
|
||||
@section('page-scripts')
|
||||
<script type="text/javascript">
|
||||
function populate(account,spinner) {
|
||||
spinner.toggleClass('d-none').toggleClass('fa-spin');
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
dataType: 'html',
|
||||
cache: false,
|
||||
url: '{{ url('r/account/invoices') }}',
|
||||
data: {
|
||||
aid: account,
|
||||
pid: {{ $po?->id ?? 'null' }},
|
||||
errors: {!! $errors !!},
|
||||
old: {!! json_encode(old()) !!}
|
||||
},
|
||||
timeout: 2000,
|
||||
error: function(x) {
|
||||
spinner.toggleClass('d-none').toggleClass('fa-spin');
|
||||
alert('Failed to submit');
|
||||
},
|
||||
success: function(data) {
|
||||
spinner.toggleClass('d-none').toggleClass('fa-spin');
|
||||
$("div[id=invoices]").empty().append(data);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function balance() {
|
||||
var alloc = 0;
|
||||
|
||||
$('input[id^=invoices_]').each(function() {
|
||||
alloc += parseFloat($(this).val());
|
||||
})
|
||||
|
||||
$('#balance').val(($('#total_amt').val()-alloc).toFixed(2))
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
if ($('#account_id').val()) {
|
||||
var spinner = $('#account_id').parent().parent().find('i.fas.fa-spinner');
|
||||
|
||||
populate($('#account_id').val(),spinner);
|
||||
}
|
||||
|
||||
$('#account_id').select2({
|
||||
sorter: data => data.sort((a, b) => a.text.localeCompare(b.text)),
|
||||
})
|
||||
.on('change',function(e) {
|
||||
if (! $(this).val()) {
|
||||
$("div[id=invoices]").empty();
|
||||
return;
|
||||
}
|
||||
|
||||
var spinner = $(this).parent().parent().find('i.fas.fa-spinner');
|
||||
|
||||
populate($(this).val(),spinner);
|
||||
});
|
||||
|
||||
|
||||
$('#total_amt').on('change',balance);
|
||||
});
|
||||
|
||||
$(document).on('change','input[id^=invoices_]',balance);
|
||||
</script>
|
||||
@append
|
@@ -1,70 +0,0 @@
|
||||
<!-- $o = Checkout::class -->
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<h3>Checkout Details</h3>
|
||||
<hr>
|
||||
@if(session()->has('success'))
|
||||
<span class="ml-3 pt-0 pb-0 pr-1 pl-1 btn btn-outline-success"><small>{{ session()->get('success') }}</small></span>
|
||||
@endif
|
||||
|
||||
<form class="g-0 needs-validation" method="POST" enctype="multipart/form-data" role="form">
|
||||
@csrf
|
||||
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<div class="row">
|
||||
<!-- Checkout Name -->
|
||||
<div class="col-9">
|
||||
<div class="form-group has-validation">
|
||||
<label for="name">Checkout Name</label>
|
||||
<input type="text" class="form-control form-control-border @error('name') is-invalid @enderror" id="name" name="name" placeholder="Supplier Name" value="{{ old('name',$o->name) }}" required>
|
||||
<span class="invalid-feedback" role="alert">
|
||||
@error('name')
|
||||
{{ $message }}
|
||||
@else
|
||||
Payment Name required.
|
||||
@enderror
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Checkout Active -->
|
||||
<div class="col-3">
|
||||
<div class="form-group">
|
||||
<div class="custom-control custom-switch custom-switch-off-danger custom-switch-on-success">
|
||||
<input type="checkbox" class="custom-control-input" id="active" name="active" {{ old('active',$o->active) ? 'checked' : '' }}>
|
||||
<label class="custom-control-label" for="active">Active</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<!-- Description -->
|
||||
<div class="col-12">
|
||||
<div class="form-group has-validation">
|
||||
<label for="description">Description</label>
|
||||
<input type="text" class="form-control form-control-border @error('description') is-invalid @enderror" id="address1" name="description" placeholder="description" value="{{ old('description',$o->description) }}">
|
||||
<span class="invalid-feedback" role="alert">
|
||||
@error('description')
|
||||
{{ $message }}
|
||||
@enderror
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<!-- Buttons -->
|
||||
<div class="col-12">
|
||||
<a href="{{ url('/home') }}" class="btn btn-danger">Cancel</a>
|
||||
@can('wholesaler')
|
||||
<button type="submit" name="submit" class="btn btn-success mr-0 float-right">@if ($o->exists)Save @else Add @endif</button>
|
||||
@endcan
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
@@ -0,0 +1,40 @@
|
||||
<!-- $o=Account::class -->
|
||||
<div>
|
||||
<label>Invoices Due</label>
|
||||
@if(($x=$o->invoices()
|
||||
->active()
|
||||
->orderBy('due_at')
|
||||
->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())
|
||||
<table class="table table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Date Issue</th>
|
||||
<th>Date Due</th>
|
||||
<th>Total</th>
|
||||
<th>Due</th>
|
||||
<th class="text-right">Apply</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
@foreach ($x as $io)
|
||||
<tr>
|
||||
<td><a href="{{ url('u/invoice',[$io->id]) }}">{{ $io->sid }}</a></td>
|
||||
<td>{{ $io->created_at->format('Y-m-d') }}</td>
|
||||
<td>{{ $io->due_at->format('Y-m-d') }}</td>
|
||||
<td>{{ number_format($io->total,2) }}</td>
|
||||
<td>{{ number_format($io->due,2) }}</td>
|
||||
<td class="text-right">
|
||||
<x-leenooks::form.text class="text-right" id="invoices_{{$io->id}}" name="invoices[{{ $io->id }}]" icon="fa-dollar-sign" old="invoices.{{$io->id}}" :value="number_format(($x=$io->payment_items->filter(fn($item)=>$item->payment_id == $pid)) ? $x->sum('amount') : 0,2)"/>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
@else
|
||||
<p>No invoices due.</p>
|
||||
@endif
|
||||
</div>
|
Reference in New Issue
Block a user