Fix payment join to show unapplied payments

This commit is contained in:
Deon George 2020-07-22 11:40:33 +10:00
parent c97835edd1
commit 9bf062e8e6
No known key found for this signature in database
GPG Key ID: 7670E8DC27415254
2 changed files with 5 additions and 4 deletions

View File

@ -618,7 +618,7 @@ class User extends Authenticatable
{ {
$payment = (new Payment) $payment = (new Payment)
->select([ ->select([
'payment_id', DB::raw('payment_id AS id'),
DB::raw('SUM(allocate) AS allocate'), DB::raw('SUM(allocate) AS allocate'),
]) ])
@ -628,14 +628,15 @@ class User extends Authenticatable
return (new Payment) return (new Payment)
->select([ ->select([
DB::raw('payment_id AS id'), DB::raw('ab_payment.id AS id'),
'date_orig', 'date_orig',
'date_payment', 'date_payment',
'total_amt', 'total_amt',
//'fees_amt', //'fees_amt',
DB::raw('total_amt-allocate AS balance'), DB::raw('total_amt-allocate AS balance'),
]) ])
->join('ab_payment',['ab_payment.id'=>'payment_id']) ->rightJoin('ab_payment',['ab_payment.id'=>'summary.id'])
//->where('ab_payment.active',TRUE) // @todo To implement
->whereIN('account_id',$this->all_accounts()->pluck('id')->unique()->toArray()) ->whereIN('account_id',$this->all_accounts()->pluck('id')->unique()->toArray())
->from($payment,'summary'); ->from($payment,'summary');
} }

View File

@ -14,7 +14,7 @@
@foreach ($x as $oo) @foreach ($x as $oo)
<tr> <tr>
<td class="text-right"><a href="{{ url('u/payment',$oo->id) }}">{{ $oo->id }}</a></td> <td class="text-right"><a href="{{ url('u/payment',$oo->id) }}">{{ $oo->id }}</a></td>
<td class="text-right">{{ $oo->date_orig->format('Y-m-d') }}</td> <td class="text-right">{{ $oo->date_payment->format('Y-m-d') }}</td>
<td class="text-right">${{ number_format($oo->total_amt,2) }}</td> <td class="text-right">${{ number_format($oo->total_amt,2) }}</td>
{{--<td class="text-right">${{ number_format($oo->balance,2) }}</td>--}} {{--<td class="text-right">${{ number_format($oo->balance,2) }}</td>--}}
<td>{!! join(',',$oo->items <td>{!! join(',',$oo->items