diff --git a/app/Http/Controllers/AdminController.php b/app/Http/Controllers/AdminController.php index 814f174..ca5334c 100644 --- a/app/Http/Controllers/AdminController.php +++ b/app/Http/Controllers/AdminController.php @@ -116,6 +116,7 @@ class AdminController extends Controller if (! $o->exists) { $o->forceFill($request->only(['account_id','paid_at','checkout_id','checkout_id','total_amt','fees_amt','source_id','pending','notes','ip'])); $o->site_id = config('site')->site_id; + $o->active = TRUE; $o->save(); } diff --git a/app/Http/Controllers/PaypalController.php b/app/Http/Controllers/PaypalController.php index e134904..02e83aa 100644 --- a/app/Http/Controllers/PaypalController.php +++ b/app/Http/Controllers/PaypalController.php @@ -200,6 +200,7 @@ class PaypalController extends Controller foreach ($response->result->purchase_units as $pu) { foreach ($pu->payments->captures as $cap) { $po = new Payment; + $po->active = TRUE; switch ($cap->status) { case 'PENDING': diff --git a/app/Jobs/PaymentsImport.php b/app/Jobs/PaymentsImport.php index 1011893..d660ee0 100644 --- a/app/Jobs/PaymentsImport.php +++ b/app/Jobs/PaymentsImport.php @@ -88,6 +88,7 @@ final class PaymentsImport implements ShouldQueue // New Payment $po = new Payment; + $po->active = TRUE; $po->site_id = 1; // @todo $po->paid_at = $pd; $po->checkout_id = '999'; // @todo diff --git a/app/Models/Invoice.php b/app/Models/Invoice.php index 8d23184..9c5f4dd 100644 --- a/app/Models/Invoice.php +++ b/app/Models/Invoice.php @@ -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'); } diff --git a/app/Models/Payment.php b/app/Models/Payment.php index 5284e55..a3fe116 100644 --- a/app/Models/Payment.php +++ b/app/Models/Payment.php @@ -24,7 +24,7 @@ use App\Traits\PushNew; */ class Payment extends Model implements IDs { - use PushNew; + use PushNew,ScopeActive; protected $dates = [ 'paid_at', diff --git a/resources/views/theme/backend/adminlte/a/payment/unapplied.blade.php b/resources/views/theme/backend/adminlte/a/payment/unapplied.blade.php index 5d1d302..7821430 100644 --- a/resources/views/theme/backend/adminlte/a/payment/unapplied.blade.php +++ b/resources/views/theme/backend/adminlte/a/payment/unapplied.blade.php @@ -32,7 +32,7 @@
- @foreach(\App\Models\Payment::unapplied()->with(['account.user','checkout','items'])->get() as $o) + @foreach(\App\Models\Payment::active()->unapplied()->with(['account.user','checkout','items'])->get() as $o) @if (! $o->balance) @continue @endif