From 8e41c801c85a5f403a2f85da28b1831efccec812 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 29 Jul 2021 20:30:02 +1000 Subject: [PATCH] minor fixes for handle reversal --- .../ClientPortal/ContactHashLoginController.php | 11 +++++++++++ app/Services/Invoice/HandleReversal.php | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/ClientPortal/ContactHashLoginController.php b/app/Http/Controllers/ClientPortal/ContactHashLoginController.php index 6d63cc06e6c8..a384fcd6d4fe 100644 --- a/app/Http/Controllers/ClientPortal/ContactHashLoginController.php +++ b/app/Http/Controllers/ClientPortal/ContactHashLoginController.php @@ -24,6 +24,17 @@ class ContactHashLoginController extends Controller */ public function login(string $contact_key) { + if(request()->has('subscription') && $request->subscription == 'true') { + + $recurring_invoice = RecurringInvoice::where('client_id', auth()->guard('contact')->client->id) + ->whereNotNull('subscription_id') + ->whereNull('deleted_at') + ->first(); + + return route('client.recurring_invoice.show', $recurring_invoice->hashed_id); + + } + return redirect('/client/invoices'); } diff --git a/app/Services/Invoice/HandleReversal.php b/app/Services/Invoice/HandleReversal.php index 469597f242e9..4c0901f2f9cf 100644 --- a/app/Services/Invoice/HandleReversal.php +++ b/app/Services/Invoice/HandleReversal.php @@ -90,7 +90,7 @@ class HandleReversal extends AbstractService } /*If there is a payment linked, then the credit needs to be linked back to that payment in case of refund*/ - if ($paymentables->count() > 0) { + if ($paymentables->count() > 0 && $credit) { $payment = $paymentables->first()->payment; $payment->credits()->save($credit);