mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Refactor quote filters
This commit is contained in:
parent
fbb137b357
commit
7290fcd05a
@ -78,6 +78,7 @@ class BankTransactionFilters extends QueryFilters
|
||||
$status_parameters = explode(',', $value);
|
||||
|
||||
$status_array = [];
|
||||
|
||||
$debit_or_withdrawal_array = [];
|
||||
|
||||
if (in_array('all', $status_parameters)) {
|
||||
|
@ -42,20 +42,26 @@ class PurchaseOrderFilters extends QueryFilters
|
||||
return $this->builder;
|
||||
}
|
||||
|
||||
$po_status = [];
|
||||
|
||||
if (in_array('draft', $status_parameters)) {
|
||||
$this->builder->where('status_id', PurchaseOrder::STATUS_DRAFT);
|
||||
$po_status[] = PurchaseOrder::STATUS_DRAFT;
|
||||
}
|
||||
|
||||
if (in_array('sent', $status_parameters)) {
|
||||
$this->builder->where('status_id', PurchaseOrder::STATUS_SENT);
|
||||
$po_status[] = PurchaseOrder::STATUS_SENT;
|
||||
}
|
||||
|
||||
if (in_array('accepted', $status_parameters)) {
|
||||
$this->builder->where('status_id', PurchaseOrder::STATUS_ACCEPTED);
|
||||
$po_status[] = PurchaseOrder::STATUS_ACCEPTED;
|
||||
}
|
||||
|
||||
if (in_array('cancelled', $status_parameters)) {
|
||||
$this->builder->where('status_id', PurchaseOrder::STATUS_CANCELLED);
|
||||
$po_status[] = PurchaseOrder::STATUS_CANCELLED;
|
||||
}
|
||||
|
||||
if(count($status_parameters) >=1) {
|
||||
$this->builder->whereIn('status_id', $status_parameters);
|
||||
}
|
||||
|
||||
return $this->builder;
|
||||
|
@ -66,25 +66,31 @@ class QuoteFilters extends QueryFilters
|
||||
return $this->builder;
|
||||
}
|
||||
|
||||
$quote_filters = [];
|
||||
|
||||
if (in_array('draft', $status_parameters)) {
|
||||
$this->builder->where('status_id', Quote::STATUS_DRAFT);
|
||||
$quote_filters[] = Quote::STATUS_DRAFT;
|
||||
}
|
||||
|
||||
if (in_array('sent', $status_parameters)) {
|
||||
$this->builder->where('status_id', Quote::STATUS_SENT);
|
||||
$quote_filters[] = Quote::STATUS_SENT;
|
||||
}
|
||||
|
||||
if (in_array('approved', $status_parameters)) {
|
||||
$this->builder->where('status_id', Quote::STATUS_APPROVED);
|
||||
$quote_filters[] = Quote::STATUS_APPROVED;
|
||||
}
|
||||
|
||||
if(count($quote_filters) >=1){
|
||||
$this->builder->whereIn('status_id', $quote_filters);
|
||||
}
|
||||
|
||||
if (in_array('expired', $status_parameters)) {
|
||||
$this->builder->where('status_id', Quote::STATUS_SENT)
|
||||
$this->builder->orWhere('status_id', Quote::STATUS_SENT)
|
||||
->where('due_date', '>=', now()->toDateString());
|
||||
}
|
||||
|
||||
if (in_array('upcoming', $status_parameters)) {
|
||||
$this->builder->where('status_id', Quote::STATUS_SENT)
|
||||
$this->builder->orWhere('status_id', Quote::STATUS_SENT)
|
||||
->where('due_date', '<=', now()->toDateString())
|
||||
->orderBy('due_date', 'DESC');
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user