Additional validation checks for ivnoices

This commit is contained in:
David Bomba 2025-03-30 07:34:53 +11:00
parent 324abde22b
commit 7fa7d5349a
1 changed files with 9 additions and 1 deletions

View File

@ -50,7 +50,15 @@ class ValidInvoiceCreditRule implements Rule
{ {
$invoice = Invoice::withTrashed()->find($value); $invoice = Invoice::withTrashed()->find($value);
if ($invoice->balance >= $invoice->amount) { if(!$invoice){
$this->error_message = 'Invoice not found.';
return false;
}
elseif ($invoice->balance >= $invoice->amount) {
$this->error_message = 'Cannot reverse an invoice with no payment applied.'; $this->error_message = 'Cannot reverse an invoice with no payment applied.';
return false; return false;