diff --git a/app/Http/Controllers/CreditController.php b/app/Http/Controllers/CreditController.php index c76bfd9e9b..e1bbb1a479 100644 --- a/app/Http/Controllers/CreditController.php +++ b/app/Http/Controllers/CreditController.php @@ -214,9 +214,14 @@ class CreditController extends BaseController if ($credit->invoice_id) { $credit = $credit->service()->markSent()->save(); $credit->client->service()->updatePaidToDate(-1 * $credit->balance)->save(); // If we mutate the paid to date, we need to reverse the status of the invoice, this will allow the credit note that has been created to be used and double paid to dates prevented. - $invoice = $credit->invoice; - $invoice->status_id = \App\Models\Invoice::STATUS_REVERSED; - $invoice->save(); + // $invoice = $credit->invoice; + + $invoice = \App\Models\Invoice::withTrashed()->find($credit->invoice_id); + if ($invoice) { + $invoice->status_id = Invoice::STATUS_REVERSED; + $invoice->save(); + } + } event(new CreditWasCreated($credit, $credit->company, Ninja::eventVars($user->id)));