Merge branch 'v5-develop' of https://github.com/turbo124/invoiceninja into v5-develop

This commit is contained in:
David Bomba 2023-12-10 13:22:59 +11:00
commit b620337348
2 changed files with 25 additions and 17 deletions

View File

@ -146,22 +146,25 @@ class InvoiceFilters extends QueryFilters
*/ */
public function upcoming(): Builder 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();
});
}) return $this->builder->where(function ($query) {
->orderByRaw('ISNULL(due_date), due_date '. 'desc') $query->whereIn('status_id', [Invoice::STATUS_PARTIAL, Invoice::STATUS_SENT])
->orderByRaw('ISNULL(partial_due_date), partial_due_date '. 'desc'); ->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 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('is_deleted', 0)
->where('balance', '>', 0)
->where(function ($query) { ->where(function ($query) {
$query->where('due_date', '<', now()) $query->where('due_date', '<', now())
->orWhere('partial_due_date', '<', now()); ->orWhere('partial_due_date', '<', now());
}) })
->orderBy('due_date', 'ASC'); ->orderBy('due_date', 'ASC');
});
} }
/** /**

View File

@ -37,7 +37,7 @@ class ImportRequest extends Request
'column_map' => 'required_with:hash|array', 'column_map' => 'required_with:hash|array',
'skip_header' => 'required_with:hash|boolean', 'skip_header' => 'required_with:hash|boolean',
'files.*' => 'file|mimes:csv,txt', 'files.*' => 'file|mimes:csv,txt',
'bank_integration_id' => 'bail|required_if:column_map,bank_transaction|min:2' 'bank_integration_id' => 'bail|required_with:column_map.bank_transaction|min:2'
]; ];
} }
} }