Payment summary improvements, removed invoice/payment API calls

This commit is contained in:
Deon George
2020-07-21 17:41:24 +10:00
parent 444f2cf52d
commit c97835edd1
10 changed files with 132 additions and 185 deletions

View File

@@ -614,6 +614,32 @@ class User extends Authenticatable
->from($summary,'summary');
}
public function query_payment_summary()
{
$payment = (new Payment)
->select([
'payment_id',
DB::raw('SUM(allocate) AS allocate'),
])
->from($this->query_payment_items(),'PI')
//->where('ab_payment.active',TRUE) // @todo To implement
->groupBy(['payment_id']);
return (new Payment)
->select([
DB::raw('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'])
->whereIN('account_id',$this->all_accounts()->pluck('id')->unique()->toArray())
->from($payment,'summary');
}
public function role()
{
// If I have agents and no parent, I am the wholesaler