Fix recording charges

This commit is contained in:
Deon George 2022-06-13 14:34:45 +10:00
parent 2590997b1a
commit 9e889008bf
4 changed files with 8 additions and 8 deletions

View File

@ -27,7 +27,7 @@ class AdminController extends Controller
if ($request->post()) {
$request->validate([
'account_id' => 'required|exists:accounts,id',
'charge_date' => 'required|date',
'charge_at' => 'required|date',
'service_id' => 'required|exists:services,id',
'quantity' => 'required|numeric|not_in:0',
'amount' => 'required|numeric|min:0.01',
@ -43,7 +43,7 @@ class AdminController extends Controller
$o->active = TRUE;
}
$o->forceFill($request->only(['account_id','charge_date','service_id','quantity','amount','sweep_type','type','taxable','description']));
$o->forceFill($request->only(['account_id','charge_at','service_id','quantity','amount','sweep_type','type','taxable','description']));
$o->save();
return redirect()->back()

View File

@ -25,7 +25,7 @@ class Charge extends Model
protected $dates = [
'start_at',
'stop_at',
'charged_at', // @todo Dont remember what this attribute is for
'charge_at', // The date the charge applies - since it can be different to created_at
];
public const sweep = [

View File

@ -32,21 +32,21 @@
<!-- DATE CHARGE -->
<div class="col-4">
<div class="form-group has-validation">
<label for="charge_date">Date Charge</label>
<label for="charge_at">Date Charge</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('charge_date') is-invalid @enderror" id="charge_date" name="charge_date" value="{{ old('charge_date',($o->exists ? $o->charge_date : \Carbon\Carbon::now())->format('Y-m-d')) }}" required>
<input type="date" class="form-control @error('charge_at') is-invalid @enderror" id="charge_at" name="charge_at" value="{{ old('charge_at',($o->exists ? $o->charge_at : \Carbon\Carbon::now())->format('Y-m-d')) }}" required>
<span class="invalid-feedback" role="alert">
@error('charge_date')
@error('charge_at')
{{ $message }}
@else
Charge Date is required.
@enderror
</span>
</div>
<span class="input-helper">Date Payment Received.</span>
<span class="input-helper">Date of Charge</span>
</div>
</div>

View File

@ -23,7 +23,7 @@
<tr>
<td><a href="{{ url('a/charge/addedit',[$co->id]) }}">{{ $co->id }}</a></td>
<td>{{ $co->created_at->format('Y-m-d') }}</td>
<td>{{ $co->charged_at ? $co->charged_at->format('Y-m-d') : '-' }}</td>
<td>{{ $co->charge_at ? $co->charge_at->format('Y-m-d') : '-' }}</td>
<td>{{ $co->service->sid }}</td>
<td>{{ $co->type }}</td>
<td>{{ $co->description }}</td>