Fixes for unique invoice number rule

This commit is contained in:
David Bomba 2020-07-23 21:30:51 +10:00
parent 41fdbd7978
commit 2f07a36d76
2 changed files with 8 additions and 4 deletions

View File

@ -148,7 +148,7 @@ class BaseController extends Controller
$query->with(
[
'company' => function ($query) use($updated_at){$query->where('updated_at', '>=', 0);},
'company' => function ($query) use($updated_at){$query->whereNotNull('updated_at');},
'company.clients' =>function ($query) use($updated_at){$query->where('updated_at', '>=', $updated_at);},
'company.tax_rates'=>function ($query) use($updated_at){$query->where('updated_at', '>=', $updated_at);},
'company.groups'=>function ($query) use($updated_at){$query->where('updated_at', '>=', $updated_at);},

View File

@ -54,13 +54,17 @@ class UniqueInvoiceNumberRule implements Rule
*
* @return bool
*/
private function checkIfInvoiceNumberUnique($value) : bool
private function checkIfInvoiceNumberUnique() : bool
{
return Invoice::where('client_id', $this->input['client_id'])
$invoice = Invoice::where('client_id', $this->input['client_id'])
->where('number', $this->input['number'])
->withTrashed()
->exists();
->first();
if($invoice)
return false;
return true;
}
}