1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00

Implement additional filters for list views

This commit is contained in:
David Bomba 2022-11-19 13:37:27 +11:00
parent 1c89a39d56
commit b988614e38
5 changed files with 142 additions and 13 deletions

View File

@ -55,6 +55,55 @@ class BankTransactionFilters extends QueryFilters
}
/**
* Filter based on client status.
*
* Statuses we need to handle
* - all
* - unmatched
* - matched
* - converted
* - deposits
* - withdrawals
*
* @return Builder
*/
public function client_status(string $value = '') :Builder
{
if (strlen($value) == 0) {
return $this->builder;
}
$status_parameters = explode(',', $value);
if (in_array('all', $status_parameters)) {
return $this->builder;
}
if (in_array('unmatched', $status_parameters)) {
$this->builder->where('status_id', BankTransaction::STATUS_UNMATCHED);
}
if (in_array('matched', $status_parameters)) {
$this->builder->where('status_id', BankTransaction::STATUS_MATCHED);
}
if (in_array('converted', $status_parameters)) {
$this->builder->where('status_id', BankTransaction::STATUS_CONVERTED);
}
if (in_array('deposits', $status_parameters)) {
$this->builder->where('base_type', 'CREDIT');
}
if (in_array('withdrawals', $status_parameters)) {
$this->builder->where('base_type', 'DEBIT');
}
return $this->builder;
}
/**
* Filters the list based on the status
* archived, active, deleted.

View File

@ -44,6 +44,55 @@ class ExpenseFilters extends QueryFilters
});
}
/**
* Filter based on client status.
*
* Statuses we need to handle
* - all
* - logged
* - pending
* - invoiced
* - paid
* - unpaid
*
* @return Builder
*/
public function client_status(string $value = '') :Builder
{
if (strlen($value) == 0) {
return $this->builder;
}
$status_parameters = explode(',', $value);
if (in_array('all', $status_parameters)) {
return $this->builder;
}
if (in_array('logged', $status_parameters)) {
$this->builder->where('amount', '>', 0);
}
if (in_array('pending', $status_parameters)) {
$this->builder->whereNull('invoice_id')->whereNotNull('payment_date');
}
if (in_array('invoiced', $status_parameters)) {
$this->builder->whereNotNull('invoice_id');
}
if (in_array('paid', $status_parameters)) {
$this->builder->whereNotNull('payment_date');
}
if (in_array('unpaid', $status_parameters)) {
$this->builder->whereNull('payment_date');
}
return $this->builder;
}
/**
* Filters the list based on the status
* archived, active, deleted.

View File

@ -17,19 +17,20 @@ use Illuminate\Database\Eloquent\Builder;
class PurchaseOrderFilters extends QueryFilters
{
/**
* Filter based on client status.
*
* Statuses we need to handle
* - all
* - paid
* - unpaid
* - overdue
* - reversed
* - draft
* - sent
* - accepted
* - cancelled
*
* @return Builder
*/
public function credit_status(string $value = '') :Builder
public function client_status(string $value = '') :Builder
{
if (strlen($value) == 0) {
return $this->builder;
@ -45,16 +46,17 @@ class PurchaseOrderFilters extends QueryFilters
$this->builder->where('status_id', PurchaseOrder::STATUS_DRAFT);
}
if (in_array('partial', $status_parameters)) {
$this->builder->where('status_id', PurchaseOrder::STATUS_PARTIAL);
if (in_array('sent', $status_parameters)) {
$this->builder->where('status_id', PurchaseOrder::STATUS_SENT);
}
if (in_array('applied', $status_parameters)) {
$this->builder->where('status_id', PurchaseOrder::STATUS_APPLIED);
if (in_array('accepted', $status_parameters)) {
$this->builder->where('status_id', PurchaseOrder::STATUS_ACCEPTED);
}
//->where('due_date', '>', Carbon::now())
//->orWhere('partial_due_date', '>', Carbon::now());
if (in_array('cancelled', $status_parameters)) {
$this->builder->where('status_id', PurchaseOrder::STATUS_CANCELLED);
}
return $this->builder;
}

View File

@ -41,6 +41,37 @@ class TaskFilters extends QueryFilters
});
}
/**
* Filter based on client status.
*
* Statuses we need to handle
* - all
* - invoiced
*
* @param string client_status The invoice status as seen by the client
* @return Builder
*/
public function client_status(string $value = '') :Builder
{
if (strlen($value) == 0) {
return $this->builder;
}
$status_parameters = explode(',', $value);
if (in_array('all', $status_parameters)) {
return $this->builder;
}
if (in_array('invoiced', $status_parameters)) {
$this->builder->whereNotNull('invoice_id');
}
return $this->builder;
}
/**
* Filters the list based on the status
* archived, active, deleted.

View File

@ -21,8 +21,6 @@ class InvoiceEmailFailedActivity implements ShouldQueue
{
protected $activity_repo;
public $delay = 5;
/**
* Create the event listener.
*