Fix payment entry

This commit is contained in:
Deon George
2022-06-13 15:46:38 +10:00
parent 9e889008bf
commit 49a4830d89
10 changed files with 42 additions and 25 deletions

View File

@@ -281,7 +281,7 @@ class Invoice extends Model implements IDs
->filter(function($item) { return ! $item->pending_status; })
->last();
return $o?->payment_date;
return $o?->paid_at;
}
/**

View File

@@ -15,7 +15,7 @@ use App\Traits\PushNew;
*
* Attributes for payments:
* + lid : Local ID for payment
* + payment_date : Date payment received
* + paid_at : Date payment received
* + sid : System ID for payment
* + total : Payment total
* + balance : Remaining credit on payment
@@ -95,9 +95,9 @@ class Payment extends Model implements IDs
public function scopeUnapplied($query)
{
return $query
->select(['payments.id','payment_date','account_id','checkout_id','total_amt',DB::raw("SUM(amount) as allocated")])
->select(['payments.id','paid_at','account_id','checkout_id','total_amt',DB::raw("SUM(amount) as allocated")])
->leftJoin('payment_items',['payment_items.payment_id'=>'payments.id'])
->groupBy(['payments.id','payment_date','total_amt','account_id','checkout_id'])
->groupBy(['payments.id','paid_at','total_amt','account_id','checkout_id'])
->having(DB::raw('ROUND(total_amt-IFNULL(allocated,0),2)'),'>',self::threshold);
}

View File

@@ -10,6 +10,8 @@ class PaymentItem extends Model
{
use PushNew;
public $timestamps = FALSE;
/* RELATIONS */
public function invoice()