mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Improvements for upcoming filters
This commit is contained in:
parent
1f2d608742
commit
56fe16e5a8
@ -146,22 +146,25 @@ class InvoiceFilters extends QueryFilters
|
||||
*/
|
||||
public function upcoming(): Builder
|
||||
{
|
||||
return $this->builder->whereIn('status_id', [Invoice::STATUS_PARTIAL, Invoice::STATUS_SENT])
|
||||
->where('is_deleted', 0)
|
||||
->where('balance', '>', 0)
|
||||
->where(function ($query) {
|
||||
|
||||
$query->whereNull('due_date')
|
||||
->orWhere(function ($q) {
|
||||
$q->where('due_date', '>=', now()->startOfDay()->subSecond())->where('partial', 0)->company();
|
||||
})
|
||||
->orWhere(function ($q) {
|
||||
$q->where('partial_due_date', '>=', now()->startOfDay()->subSecond())->where('partial', '>', 0)->company();
|
||||
});
|
||||
|
||||
})
|
||||
->orderByRaw('ISNULL(due_date), due_date '. 'desc')
|
||||
->orderByRaw('ISNULL(partial_due_date), partial_due_date '. 'desc');
|
||||
return $this->builder->where(function ($query) {
|
||||
$query->whereIn('status_id', [Invoice::STATUS_PARTIAL, Invoice::STATUS_SENT])
|
||||
->where('is_deleted', 0)
|
||||
->where('balance', '>', 0)
|
||||
->where(function ($query) {
|
||||
|
||||
$query->whereNull('due_date')
|
||||
->orWhere(function ($q) {
|
||||
$q->where('due_date', '>=', now()->startOfDay()->subSecond())->where('partial', 0);
|
||||
})
|
||||
->orWhere(function ($q) {
|
||||
$q->where('partial_due_date', '>=', now()->startOfDay()->subSecond())->where('partial', '>', 0);
|
||||
});
|
||||
|
||||
})
|
||||
->orderByRaw('ISNULL(due_date), due_date ' . 'desc')
|
||||
->orderByRaw('ISNULL(partial_due_date), partial_due_date ' . 'desc');
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@ -172,13 +175,18 @@ class InvoiceFilters extends QueryFilters
|
||||
*/
|
||||
public function overdue(): Builder
|
||||
{
|
||||
return $this->builder->whereIn('status_id', [Invoice::STATUS_SENT, Invoice::STATUS_PARTIAL])
|
||||
return $this->builder->where(function ($query) {
|
||||
|
||||
$query->whereIn('status_id', [Invoice::STATUS_SENT, Invoice::STATUS_PARTIAL])
|
||||
->where('is_deleted', 0)
|
||||
->where('balance', '>', 0)
|
||||
->where(function ($query) {
|
||||
$query->where('due_date', '<', now())
|
||||
->orWhere('partial_due_date', '<', now());
|
||||
})
|
||||
->orderBy('due_date', 'ASC');
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user