Payments need to be active to be recognised

This commit is contained in:
Deon George
2022-06-13 17:24:43 +10:00
parent 28438c6423
commit 5e82f091c0
7 changed files with 9 additions and 5 deletions

View File

@@ -195,7 +195,8 @@ class Invoice extends Model implements IDs
public function payments()
{
return $this->hasManyThrough(Payment::class,PaymentItem::class,NULL,'id',NULL,'payment_id');
return $this->hasManyThrough(Payment::class,PaymentItem::class,NULL,'id',NULL,'payment_id')
->active();
}
public function paymentitems()
@@ -262,7 +263,7 @@ class Invoice extends Model implements IDs
public function getPaidAttribute(): float
{
return $this->paymentitems
->filter(function($item) { return ! $item->payment->pending_status; })
->filter(function($item) { return ! $item->payment->pending_status && $item->payment->active; })
->sum('amount');
}

View File

@@ -24,7 +24,7 @@ use App\Traits\PushNew;
*/
class Payment extends Model implements IDs
{
use PushNew;
use PushNew,ScopeActive;
protected $dates = [
'paid_at',