Payments need to be active to be recognised
This commit is contained in:
@@ -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');
|
||||
}
|
||||
|
||||
|
@@ -24,7 +24,7 @@ use App\Traits\PushNew;
|
||||
*/
|
||||
class Payment extends Model implements IDs
|
||||
{
|
||||
use PushNew;
|
||||
use PushNew,ScopeActive;
|
||||
|
||||
protected $dates = [
|
||||
'paid_at',
|
||||
|
Reference in New Issue
Block a user