mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Fixes for expense filters
This commit is contained in:
parent
d43ce15dff
commit
317204c88a
@ -69,25 +69,54 @@ class ExpenseFilters extends QueryFilters
|
||||
return $this->builder;
|
||||
}
|
||||
|
||||
if (in_array('logged', $status_parameters)) {
|
||||
$this->builder->where('amount', '>', 0);
|
||||
}
|
||||
$this->builder->whereNested(function ($query) use($status_parameters){
|
||||
|
||||
if (in_array('pending', $status_parameters)) {
|
||||
$this->builder->whereNull('invoice_id')->whereNotNull('payment_date');
|
||||
}
|
||||
if (in_array('logged', $status_parameters)) {
|
||||
|
||||
if (in_array('invoiced', $status_parameters)) {
|
||||
$this->builder->whereNotNull('invoice_id');
|
||||
}
|
||||
$query->orWhere(function ($query){
|
||||
$query->where('amount', '>', 0)
|
||||
->whereNull('invoice_id')
|
||||
->whereNull('payment_date');
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
if (in_array('paid', $status_parameters)) {
|
||||
$this->builder->whereNotNull('payment_date');
|
||||
}
|
||||
if (in_array('pending', $status_parameters)) {
|
||||
|
||||
if (in_array('unpaid', $status_parameters)) {
|
||||
$this->builder->whereNull('payment_date');
|
||||
}
|
||||
$query->orWhere(function ($query){
|
||||
$query->where('should_be_invoiced',true)
|
||||
->whereNull('invoice_id');
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
if (in_array('invoiced', $status_parameters)) {
|
||||
|
||||
$query->orWhere(function ($query){
|
||||
$query->whereNotNull('invoice_id');
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
if (in_array('paid', $status_parameters)) {
|
||||
|
||||
$query->orWhere(function ($query){
|
||||
$query->whereNotNull('payment_date');
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
if (in_array('unpaid', $status_parameters)) {
|
||||
|
||||
$query->orWhere(function ($query){
|
||||
$query->whereNull('payment_date');
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// nlog($this->builder->toSql());
|
||||
|
||||
return $this->builder;
|
||||
}
|
||||
@ -212,8 +241,6 @@ class ExpenseFilters extends QueryFilters
|
||||
*/
|
||||
public function entityFilter()
|
||||
{
|
||||
|
||||
//return $this->builder->whereCompanyId(auth()->user()->company()->id);
|
||||
return $this->builder->company();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user