Fix payment entry

This commit is contained in:
Deon George
2022-06-13 15:46:38 +10:00
parent 9e889008bf
commit 49a4830d89
10 changed files with 42 additions and 25 deletions

View File

@@ -16,7 +16,6 @@
@section('main-content')
<div class="row">
<div class="col-6">
<div class="card card-dark">
<div class="card-header">
<h1 class="card-title">Record Payment</h1>
@@ -33,14 +32,14 @@
<!-- DATE RECEIVED -->
<div class="col-4">
<div class="form-group has-validation">
<label for="payment_date">Date Received</label>
<label for="paid_at">Date Received</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fas fa-fw fa-calendar"></i></span>
</div>
<input type="date" class="form-control @error('payment_date') is-invalid @enderror" id="payment_date" name="payment_date" value="{{ old('payment_date',($o->exists ? $o->payment_date : \Carbon\Carbon::now())->format('Y-m-d')) }}" required>
<input type="date" class="form-control @error('paid_at') is-invalid @enderror" id="paid_at" name="paid_at" value="{{ old('paid_at',($o->exists ? $o->paid_at : \Carbon\Carbon::now())->format('Y-m-d')) }}" required>
<span class="invalid-feedback" role="alert">
@error('payment_date')
@error('paid_at')
{{ $message }}
@else
Payment Date is required.

View File

@@ -36,7 +36,7 @@
@if (! $o->balance) @continue @endif
<tr>
<td><a href="{{ url('a/payment/addedit',$o->id) }}">{{ $o->id }}</td>
<td>{{ $o->payment_date->format('Y-m-d') }}</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>

View File

@@ -2,7 +2,7 @@
<label for="checkout_id">Invoices Due</label>
@if(($x=$o->invoices()
->where('active',TRUE)
->orderBy('due_date')
->orderBy('due_at')
->with(['items.taxes','paymentitems.payment','account'])
->get()
->filter(function($item) use ($pid) { return $item->due > 0 || $item->payments->search(function($item) use ($pid) { return $item->id == $pid; }) !== FALSE; }))->count())
@@ -23,11 +23,11 @@
<tr>
<td><a href="{{ url('u/invoice',[$io->id]) }}">{{ $io->sid }}</a></td>
<td>{{ $io->invoice_date->format('Y-m-d') }}</td>
<td>{{ $io->due_date->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">
<input type="text" class="text-right invoice" name="invoices[{{ $io->id }}]" value="{{ number_format(($x=$io->paymentitems->filter(function($item) use ($pid) { return $item->payment_id == $pid; })) ? $x->sum('amount') : 0,2) }}">
<input type="text" class="text-right invoice" name="invoices[{{ $io->id }}][id]" value="{{ number_format(($x=$io->paymentitems->filter(function($item) use ($pid) { return $item->payment_id == $pid; })) ? $x->sum('amount') : 0,2) }}">
</td>
</tr>
@endforeach