From 651aae061611833f4bb585ebfd2086fe04d28616 Mon Sep 17 00:00:00 2001 From: denisdulici Date: Fri, 9 Mar 2018 22:00:17 +0300 Subject: [PATCH] fixed #259 --- app/Console/Commands/BillReminder.php | 2 +- app/Console/Commands/InvoiceReminder.php | 2 +- app/Models/Expense/Bill.php | 10 ++++++++++ app/Models/Income/Invoice.php | 10 ++++++++++ 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/app/Console/Commands/BillReminder.php b/app/Console/Commands/BillReminder.php index 1e460d0d6..8c5cf2a1e 100644 --- a/app/Console/Commands/BillReminder.php +++ b/app/Console/Commands/BillReminder.php @@ -73,7 +73,7 @@ class BillReminder extends Command $date = Date::today()->addDays($day)->toDateString(); // Get upcoming bills - $bills = Bill::with('vendor')->accrued()->due($date)->get(); + $bills = Bill::with('vendor')->accrued()->notPaid()->due($date)->get(); foreach ($bills as $bill) { // Notify all users assigned to this company diff --git a/app/Console/Commands/InvoiceReminder.php b/app/Console/Commands/InvoiceReminder.php index 73a8e025f..bb10f505e 100644 --- a/app/Console/Commands/InvoiceReminder.php +++ b/app/Console/Commands/InvoiceReminder.php @@ -73,7 +73,7 @@ class InvoiceReminder extends Command $date = Date::today()->subDays($day)->toDateString(); // Get upcoming bills - $invoices = Invoice::with('customer')->accrued()->due($date)->get(); + $invoices = Invoice::with('customer')->accrued()->notPaid()->due($date)->get(); foreach ($invoices as $invoice) { // Notify the customer diff --git a/app/Models/Expense/Bill.php b/app/Models/Expense/Bill.php index e6b7d1657..578bd5f62 100644 --- a/app/Models/Expense/Bill.php +++ b/app/Models/Expense/Bill.php @@ -103,6 +103,16 @@ class Bill extends Model return $query->where('bill_status_code', '<>', 'draft'); } + public function scopePaid($query) + { + return $query->where('bill_status_code', '=', 'paid'); + } + + public function scopeNotPaid($query) + { + return $query->where('bill_status_code', '<>', 'paid'); + } + public function onCloning($src, $child = null) { $this->bill_status_code = 'draft'; diff --git a/app/Models/Income/Invoice.php b/app/Models/Income/Invoice.php index 859bc050e..bab404484 100644 --- a/app/Models/Income/Invoice.php +++ b/app/Models/Income/Invoice.php @@ -111,6 +111,16 @@ class Invoice extends Model return $query->where('invoice_status_code', '<>', 'draft'); } + public function scopePaid($query) + { + return $query->where('invoice_status_code', '=', 'paid'); + } + + public function scopeNotPaid($query) + { + return $query->where('invoice_status_code', '<>', 'paid'); + } + public function onCloning($src, $child = null) { $this->invoice_status_code = 'draft';