Merge pull request #6361 from turbo124/v5-develop

minor fixes for handle reversal
This commit is contained in:
David Bomba 2021-07-29 20:31:40 +10:00 committed by GitHub
commit 01e608c107
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 1 deletions

View File

@ -12,6 +12,7 @@
namespace App\Http\Controllers\ClientPortal;
use App\Http\Controllers\Controller;
use App\Models\RecurringInvoice;
use Auth;
class ContactHashLoginController extends Controller
@ -24,6 +25,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 redirect()->route('client.recurring_invoice.show', $recurring_invoice->hashed_id);
}
return redirect('/client/invoices');
}

View File

@ -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);