Minor job cleanup, import Ezypay payments update

This commit is contained in:
Deon George
2021-07-29 13:11:14 +10:00
parent 10e6c73b2b
commit 00f215b780
6 changed files with 134 additions and 123 deletions

View File

@@ -74,11 +74,12 @@ class Payment extends Model implements IDs
public function scopeUnapplied($query)
{
//DB::enableQueryLog();
return $query
->select([DB::raw('payment_id AS id'),'payment_date','account_id','checkout_id','total_amt',DB::raw("SUM(alloc_amt) as allocated")])
->join('payment_items',['payment_items.payment_id'=>'payments.id'])
->groupBy(['payment_id','payment_date','total_amt','account_id','checkout_id'])
->having(DB::raw("ROUND(total_amt-allocated,2)"),'>',self::threshold);
->select(['payments.id','payment_date','account_id','checkout_id','total_amt',DB::raw("SUM(alloc_amt) as allocated")])
->leftJoin('payment_items',['payment_items.payment_id'=>'payments.id'])
->groupBy(['payments.id','payment_date','total_amt','account_id','checkout_id'])
->having(DB::raw('ROUND(total_amt-IFNULL(allocated,0),2)'),'>',self::threshold);
}
/* ATTRIBUTES */