mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-08 20:22:42 +01:00
Fix problem clearing duplicate invoice number error
This commit is contained in:
parent
ef29c549ef
commit
b624bb13c3
@ -429,7 +429,7 @@ class InvoiceController extends BaseController
|
||||
{
|
||||
$data = $request->input();
|
||||
$data['documents'] = $request->file('documents');
|
||||
|
||||
|
||||
$action = Input::get('action');
|
||||
$entityType = Input::get('entityType');
|
||||
|
||||
@ -606,14 +606,19 @@ class InvoiceController extends BaseController
|
||||
return View::make('invoices.history', $data);
|
||||
}
|
||||
|
||||
public function checkInvoiceNumber()
|
||||
public function checkInvoiceNumber($invoicePublicId = false)
|
||||
{
|
||||
$invoiceNumber = request()->invoice_number;
|
||||
|
||||
$count = Invoice::scope()
|
||||
$query = Invoice::scope()
|
||||
->whereInvoiceNumber($invoiceNumber)
|
||||
->withTrashed()
|
||||
->count();
|
||||
->withTrashed();
|
||||
|
||||
if ($invoicePublicId) {
|
||||
$query->where('public_id', '!=', $invoicePublicId);
|
||||
}
|
||||
|
||||
$count = $query->count();
|
||||
|
||||
return $count ? RESULT_FAILURE : RESULT_SUCCESS;
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ Route::group(['middleware' => 'auth:user'], function() {
|
||||
Route::get('hide_message', 'HomeController@hideMessage');
|
||||
Route::get('force_inline_pdf', 'UserController@forcePDFJS');
|
||||
Route::get('account/get_search_data', ['as' => 'get_search_data', 'uses' => 'AccountController@getSearchData']);
|
||||
Route::get('check_invoice_number', 'InvoiceController@checkInvoiceNumber');
|
||||
Route::get('check_invoice_number/{invoice_id?}', 'InvoiceController@checkInvoiceNumber');
|
||||
Route::get('save_sidebar_state', 'UserController@saveSidebarState');
|
||||
|
||||
Route::get('settings/user_details', 'AccountController@showUserDetails');
|
||||
|
@ -853,7 +853,7 @@ ko.bindingHandlers.productTypeahead = {
|
||||
};
|
||||
|
||||
function checkInvoiceNumber() {
|
||||
var url = '{{ url('check_invoice_number') }}?invoice_number=' + encodeURIComponent($('#invoice_number').val());
|
||||
var url = '{{ url('check_invoice_number') }}/{{ $invoice->exists ? $invoice->public_id : '' }}?invoice_number=' + encodeURIComponent($('#invoice_number').val());
|
||||
$.get(url, function(data) {
|
||||
var isValid = data == '{{ RESULT_SUCCESS }}' ? true : false;
|
||||
if (isValid) {
|
||||
|
Loading…
Reference in New Issue
Block a user