This commit is contained in:
denisdulici 2018-03-09 22:00:17 +03:00
parent b51163ae02
commit 651aae0616
4 changed files with 22 additions and 2 deletions

View File

@ -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

View File

@ -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

View File

@ -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';

View File

@ -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';