mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Fixes for invoice filtering and partial due date validations
This commit is contained in:
parent
839ca6c7cf
commit
905d1a3f85
@ -147,11 +147,15 @@ class InvoiceFilters extends QueryFilters
|
|||||||
public function upcoming(): Builder
|
public function upcoming(): Builder
|
||||||
{
|
{
|
||||||
return $this->builder->whereIn('status_id', [Invoice::STATUS_PARTIAL, Invoice::STATUS_SENT])
|
return $this->builder->whereIn('status_id', [Invoice::STATUS_PARTIAL, Invoice::STATUS_SENT])
|
||||||
->where(function ($query) {
|
->whereNull('due_date')
|
||||||
$query->whereNull('due_date')
|
->orWhere(function ($q) {
|
||||||
->orWhere('due_date', '>', now());
|
$q->where('due_date', '>=', now()->startOfDay()->subSecond())->where('partial', 0);
|
||||||
})
|
})
|
||||||
->orderBy('due_date', 'ASC');
|
->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');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -74,7 +74,7 @@ class StoreInvoiceRequest extends Request
|
|||||||
$rules['tax_name3'] = 'bail|sometimes|string|nullable';
|
$rules['tax_name3'] = 'bail|sometimes|string|nullable';
|
||||||
$rules['exchange_rate'] = 'bail|sometimes|numeric';
|
$rules['exchange_rate'] = 'bail|sometimes|numeric';
|
||||||
$rules['partial'] = 'bail|sometimes|nullable|numeric|gte:0';
|
$rules['partial'] = 'bail|sometimes|nullable|numeric|gte:0';
|
||||||
$rules['partial_due_date'] = ['bail', 'sometimes', 'exclude_if:partial,0', Rule::requiredIf(fn () => $this->partial > 0), 'date'];
|
$rules['partial_due_date'] = ['bail', 'sometimes', 'exclude_if:partial,0', Rule::requiredIf(fn () => $this->partial > 0), 'date', 'before:due_date'];
|
||||||
|
|
||||||
return $rules;
|
return $rules;
|
||||||
}
|
}
|
||||||
@ -89,6 +89,10 @@ class StoreInvoiceRequest extends Request
|
|||||||
$input['line_items'] = isset($input['line_items']) ? $this->cleanItems($input['line_items']) : [];
|
$input['line_items'] = isset($input['line_items']) ? $this->cleanItems($input['line_items']) : [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(isset($input['partial']) && $input['partial'] == 0 && isset($input['partial_due_date'])) {
|
||||||
|
$input['partial_due_date'] = '';
|
||||||
|
}
|
||||||
|
|
||||||
$input['amount'] = 0;
|
$input['amount'] = 0;
|
||||||
$input['balance'] = 0;
|
$input['balance'] = 0;
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ class UpdateInvoiceRequest extends Request
|
|||||||
$rules['status_id'] = 'bail|sometimes|not_in:5'; //do not allow cancelled invoices to be modfified.
|
$rules['status_id'] = 'bail|sometimes|not_in:5'; //do not allow cancelled invoices to be modfified.
|
||||||
$rules['exchange_rate'] = 'bail|sometimes|numeric';
|
$rules['exchange_rate'] = 'bail|sometimes|numeric';
|
||||||
$rules['partial'] = 'bail|sometimes|nullable|numeric';
|
$rules['partial'] = 'bail|sometimes|nullable|numeric';
|
||||||
$rules['partial_due_date'] = ['bail', 'sometimes', 'exclude_if:partial,0', Rule::requiredIf(fn () => $this->partial > 0), 'date'];
|
$rules['partial_due_date'] = ['bail', 'sometimes', 'exclude_if:partial,0', Rule::requiredIf(fn () => $this->partial > 0), 'date', 'before:due_date'];
|
||||||
|
|
||||||
return $rules;
|
return $rules;
|
||||||
}
|
}
|
||||||
@ -89,6 +89,10 @@ class UpdateInvoiceRequest extends Request
|
|||||||
|
|
||||||
$input['id'] = $this->invoice->id;
|
$input['id'] = $this->invoice->id;
|
||||||
|
|
||||||
|
if(isset($input['partial']) && $input['partial'] == 0 && isset($input['partial_due_date'])) {
|
||||||
|
$input['partial_due_date'] = '';
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($input['line_items']) && is_array($input['line_items'])) {
|
if (isset($input['line_items']) && is_array($input['line_items'])) {
|
||||||
$input['line_items'] = isset($input['line_items']) ? $this->cleanItems($input['line_items']) : [];
|
$input['line_items'] = isset($input['line_items']) ? $this->cleanItems($input['line_items']) : [];
|
||||||
}
|
}
|
||||||
|
@ -3372,7 +3372,7 @@ $lang = array(
|
|||||||
'credit_number_counter' => 'Credit Number Counter',
|
'credit_number_counter' => 'Credit Number Counter',
|
||||||
'reset_counter_date' => 'Reset Counter Date',
|
'reset_counter_date' => 'Reset Counter Date',
|
||||||
'counter_padding' => 'Counter Padding',
|
'counter_padding' => 'Counter Padding',
|
||||||
'shared_invoice_quote_counter' => 'Share Invoice Quote Counter',
|
'shared_invoice_quote_counter' => 'Share Invoice/Quote Counter',
|
||||||
'default_tax_name_1' => 'Default Tax Name 1',
|
'default_tax_name_1' => 'Default Tax Name 1',
|
||||||
'default_tax_rate_1' => 'Default Tax Rate 1',
|
'default_tax_rate_1' => 'Default Tax Rate 1',
|
||||||
'default_tax_name_2' => 'Default Tax Name 2',
|
'default_tax_name_2' => 'Default Tax Name 2',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user