mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04: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 = $request->input();
|
||||||
$data['documents'] = $request->file('documents');
|
$data['documents'] = $request->file('documents');
|
||||||
|
|
||||||
$action = Input::get('action');
|
$action = Input::get('action');
|
||||||
$entityType = Input::get('entityType');
|
$entityType = Input::get('entityType');
|
||||||
|
|
||||||
@ -606,14 +606,19 @@ class InvoiceController extends BaseController
|
|||||||
return View::make('invoices.history', $data);
|
return View::make('invoices.history', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function checkInvoiceNumber()
|
public function checkInvoiceNumber($invoicePublicId = false)
|
||||||
{
|
{
|
||||||
$invoiceNumber = request()->invoice_number;
|
$invoiceNumber = request()->invoice_number;
|
||||||
|
|
||||||
$count = Invoice::scope()
|
$query = Invoice::scope()
|
||||||
->whereInvoiceNumber($invoiceNumber)
|
->whereInvoiceNumber($invoiceNumber)
|
||||||
->withTrashed()
|
->withTrashed();
|
||||||
->count();
|
|
||||||
|
if ($invoicePublicId) {
|
||||||
|
$query->where('public_id', '!=', $invoicePublicId);
|
||||||
|
}
|
||||||
|
|
||||||
|
$count = $query->count();
|
||||||
|
|
||||||
return $count ? RESULT_FAILURE : RESULT_SUCCESS;
|
return $count ? RESULT_FAILURE : RESULT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -129,7 +129,7 @@ Route::group(['middleware' => 'auth:user'], function() {
|
|||||||
Route::get('hide_message', 'HomeController@hideMessage');
|
Route::get('hide_message', 'HomeController@hideMessage');
|
||||||
Route::get('force_inline_pdf', 'UserController@forcePDFJS');
|
Route::get('force_inline_pdf', 'UserController@forcePDFJS');
|
||||||
Route::get('account/get_search_data', ['as' => 'get_search_data', 'uses' => 'AccountController@getSearchData']);
|
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('save_sidebar_state', 'UserController@saveSidebarState');
|
||||||
|
|
||||||
Route::get('settings/user_details', 'AccountController@showUserDetails');
|
Route::get('settings/user_details', 'AccountController@showUserDetails');
|
||||||
|
@ -853,7 +853,7 @@ ko.bindingHandlers.productTypeahead = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function checkInvoiceNumber() {
|
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) {
|
$.get(url, function(data) {
|
||||||
var isValid = data == '{{ RESULT_SUCCESS }}' ? true : false;
|
var isValid = data == '{{ RESULT_SUCCESS }}' ? true : false;
|
||||||
if (isValid) {
|
if (isValid) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user