1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 05:02:36 +01:00

Improve filtering of Lists by clients

This commit is contained in:
David Bomba 2023-06-22 17:46:17 +10:00
parent 08f86419b4
commit 327c782ba5
7 changed files with 43 additions and 7 deletions

View File

@ -115,6 +115,11 @@ class CreditFilters extends QueryFilters
return $this->builder;
}
if ($sort_col[0] == 'client_id') {
return $this->builder->orderBy(\App\Models\Client::select('name')
->whereColumn('clients.id', 'credits.client_id'), $sort_col[1]);
}
return $this->builder->orderBy($sort_col[0], $sort_col[1]);
}

View File

@ -11,12 +11,14 @@
namespace App\Filters;
use RuntimeException;
use App\Models\Client;
use App\Models\Invoice;
use App\Filters\QueryFilters;
use InvalidArgumentException;
use Illuminate\Support\Carbon;
use App\Utils\Traits\MakesHash;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Carbon;
use InvalidArgumentException;
use RuntimeException;
/**
* InvoiceFilters.
@ -205,10 +207,9 @@ class InvoiceFilters extends QueryFilters
}
if ($sort_col[0] == 'client_id') {
$this->builder->with(['client' => function($q) use($sort_col){
$q->orderBy('name', $sort_col[1]);
}]);
return $this->builder->orderBy(\App\Models\Client::select('name')
->whereColumn('clients.id', 'invoices.client_id'), $sort_col[1]);
}

View File

@ -158,6 +158,13 @@ class PaymentFilters extends QueryFilters
return $this->builder;
}
if ($sort_col[0] == 'client_id') {
return $this->builder->orderBy(\App\Models\Client::select('name')
->whereColumn('clients.id', 'payments.client_id'), $sort_col[1]);
}
return $this->builder->orderBy($sort_col[0], $sort_col[1]);
}

View File

@ -135,6 +135,13 @@ class QuoteFilters extends QueryFilters
return $this->builder;
}
if($sort_col[0] == 'client_id'){
return $this->builder->orderBy(\App\Models\Client::select('name')
->whereColumn('clients.id', 'quotes.client_id'), $sort_col[1]);
}
if ($sort_col[0] == 'valid_until') {
$sort_col[0] = 'due_date';
}

View File

@ -115,6 +115,13 @@ class RecurringInvoiceFilters extends QueryFilters
return $this->builder;
}
if ($sort_col[0] == 'client_id') {
return $this->builder->orderBy(\App\Models\Client::select('name')
->whereColumn('clients.id', 'recurring_invoices.client_id'), $sort_col[1]);
}
return $this->builder->orderBy($sort_col[0], $sort_col[1]);
}

View File

@ -110,6 +110,13 @@ class TaskFilters extends QueryFilters
return $this->builder;
}
if ($sort_col[0] == 'client_id') {
return $this->builder->orderBy(\App\Models\Client::select('name')
->whereColumn('clients.id', 'tasks.client_id'), $sort_col[1]);
}
return $this->builder->orderBy($sort_col[0], $sort_col[1]);
}

View File

@ -146,6 +146,8 @@ class UpdateTaxData implements ShouldQueue
public function failed($exception)
{
nlog("UpdateTaxData failed => ".$exception->getMessage());
config(['queue.failed.driver' => null]);
}
}