Add account next invoice

This commit is contained in:
2024-07-31 22:36:28 +10:00
parent 0b5bc9e012
commit f43748e20a
9 changed files with 109 additions and 96 deletions

View File

@@ -0,0 +1,35 @@
<!-- $o=Account::class -->
@use(Carbon\Carbon)
<!-- Show next items for an invoice -->
@if(($x=$o->invoice_next())->count())
<div class="card">
<div class="card-body">
<p>The following items will be invoiced on or after <strong>{{ max($x->first()->start_at->subDays(config('osb.invoice_days')),Carbon::now())->format('Y-m-d') }}</strong></p>
<table class="table table-sm table-stripped">
<!-- Group by Service -->
@foreach ($x->groupBy('service_id') as $id => $oo)
<tr>
<td>{{ $oo->first()?->product?->category_name ?: '-' }}</td>
<td>
@if($id)
<a href="{{ url('u/service',$oo->first()->service_id) }}">{{ $oo->first()->service->name }}</a>
@else
Account Charges
@endif
</td>
<td class="text-right">${{ number_format($oo->sum('total'),2) }}</td>
</tr>
@endforeach
<tr>
<th class="text-right" colspan="2">TOTAL</th>
<th class="text-right">${{ number_format($x->sum('total'),2) }}</th>
</tr>
</table>
</div>
</div>
@else
<p>No items currently due to invoice.</p>
@endif

View File

@@ -27,7 +27,7 @@
<td>{{ $so->product->category_name }}</td>
<td>{{ $so->name_short }}</td>
<td>{{ $so->product->name }}</td>
<td>{{ $so->external_billing ? '-' : $so->invoice_next->format('Y-m-d') }}</td>
<td>{{ ($so->external_billing || (! $so->invoice_next)) ? '-' : $so->invoice_next->format('Y-m-d') }}</td>
</tr>
@endforeach
</tbody>

View File

@@ -30,6 +30,7 @@
<th>Service</th>
<th>Description</th>
<th class="text-right">Total</th>
<th>&nbsp;</th>
</tr>
</thead>
@@ -42,7 +43,8 @@
<td>{{ $o->account->name }}</td>
<td><a href="{{ url('u/service',$o->service_id) }}">{{ $o->service->name_short }}</a></td>
<td>{{ $o->description }}</td>
<td class="text-right">{{ number_format($o->quantity*$o->amount,2) }}</td>
<td class="text-right">{{ number_format($o->total,2) }}</td>
<td><a class="charge_delete text-dark" data-id="{{ $o->id }}" href="{{ url('/r/charge/delete',$o->id) }}"><i class="fas fa-fw fa-ban"></i></a></td>
</tr>
@empty
<tr>
@@ -55,18 +57,21 @@
</div>
</div>
</div>
<x-leenooks::modal.delete hide="row" trigger="charge_delete"/>
@endsection
@section('page-styles')
@css(datatables,bootstrap4)
@append
@section('page-scripts')
@js(datatables,bootstrap4)
@pa(datatables,rowgroup|conditionalpaging)
@section('page-scripts')
<script type="text/javascript">
$(document).ready(function() {
$('#unprocessed_charges').DataTable( {
order: [1,'desc'],
$('#unprocessed_charges').DataTable({
conditionalPaging: true,
order: [[3,'desc'],[1,'desc']],
rowGroup: {
dataSrc: [3],
},
});
});
</script>

View File

@@ -76,7 +76,7 @@
<div class="tab-pane fade" id="tab-futureinvoice">
<div class="row">
<div class="col-12 col-xl-9">
@include('theme.backend.adminlte.invoice.widget.next',['future'=>TRUE])
@include('theme.backend.adminlte.account.widget.invoice_next',['o'=>$ao])
</div>
</div>
</div>

View File

@@ -1,41 +0,0 @@
<!-- @todo These needs to be optimised, and change for $o = Account::class -->
<!-- Show next items for an invoice -->
@if(($x=$o->next_invoice_items($future))->count())
<div class="card">
<div class="card-body">
<table class="table">
<!-- Group by Account -->
@foreach ($x->groupBy('product_id') as $id => $oo)
<tr>
<th colspan="4">{{ $oo->first()->product->name }}</th>
<th class="text-right">${{ number_format($oo->sum('total'),2) }}</th>
</tr>
@foreach ($oo->groupBy('service_id') as $ooo)
<tr>
<td class="pt-0 pb-1" style="width: 12em;"><a href="{{ url('u/service',$ooo->first()->service_id) }}">{{ $ooo->first()->service->sid }}</a></td>
<td class="pt-0 pb-1" colspan="3">{{ $ooo->first()->service->name }}</td>
</tr>
@foreach ($ooo as $io)
<tr>
<td class="pt-0 pb-1">&nbsp;</td>
<td class="pt-0 pb-1">&nbsp;</td>
<td class="pt-0 pb-1">{{ $io->item_type_name }}</td>
<td class="text-right pt-0 pb-1">${{ number_format($io->total,2) }}</td>
</tr>
@endforeach
@endforeach
@endforeach
<tr>
<th class="text-right" colspan="4">TOTAL</th>
<th class="text-right">${{ number_format($x->sum('total'),2) }}</th>
</tr>
</table>
</div>
</div>
@else
<p>No items currently due to invoice.</p>
@endif