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
2 changed files with 5 additions and 4 deletions

View File

@@ -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');
}