From 9bf062e8e6a9639dfd48cfdf43d7e4126fa2331b Mon Sep 17 00:00:00 2001 From: Deon George Date: Wed, 22 Jul 2020 11:40:33 +1000 Subject: [PATCH] Fix payment join to show unapplied payments --- app/User.php | 7 ++++--- .../views/theme/backend/adminlte/widgets/payment.blade.php | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/User.php b/app/User.php index 90c6efb..9fb3dcf 100644 --- a/app/User.php +++ b/app/User.php @@ -618,7 +618,7 @@ class User extends Authenticatable { $payment = (new Payment) ->select([ - 'payment_id', + DB::raw('payment_id AS id'), DB::raw('SUM(allocate) AS allocate'), ]) @@ -628,14 +628,15 @@ class User extends Authenticatable return (new Payment) ->select([ - DB::raw('payment_id AS id'), + DB::raw('ab_payment.id AS id'), 'date_orig', 'date_payment', 'total_amt', //'fees_amt', 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()) ->from($payment,'summary'); } diff --git a/resources/views/theme/backend/adminlte/widgets/payment.blade.php b/resources/views/theme/backend/adminlte/widgets/payment.blade.php index 60729f2..9987410 100644 --- a/resources/views/theme/backend/adminlte/widgets/payment.blade.php +++ b/resources/views/theme/backend/adminlte/widgets/payment.blade.php @@ -14,7 +14,7 @@ @foreach ($x as $oo) {{ $oo->id }} - {{ $oo->date_orig->format('Y-m-d') }} + {{ $oo->date_payment->format('Y-m-d') }} ${{ number_format($oo->total_amt,2) }} {{--${{ number_format($oo->balance,2) }}--}} {!! join(',',$oo->items