diff --git a/app/Http/Controllers/ClientPortal/PaymentController.php b/app/Http/Controllers/ClientPortal/PaymentController.php index 693d42351edf..dd7405278f17 100644 --- a/app/Http/Controllers/ClientPortal/PaymentController.php +++ b/app/Http/Controllers/ClientPortal/PaymentController.php @@ -149,12 +149,18 @@ class PaymentController extends Controller $payment = $payment->service()->applyCredits($payment_hash)->save(); $invoices = Invoice::whereIn('id', $this->transformKeys(array_column($payment_hash->invoices(), 'invoice_id'))); + + $invoices->each(function ($i){ + $i->is_proforma = false; + $i->saveQuietly(); + }); event('eloquent.created: App\Models\Payment', $payment); if($invoices->sum('balance') > 0){ $invoice = $invoices->first(); + $invoice->service()->touchPdf(true); return redirect()->route('client.invoice.show', ['invoice' => $invoice->hashed_id, 'hash' => $request->input('hash')]); } diff --git a/app/Http/Livewire/InvoicesTable.php b/app/Http/Livewire/InvoicesTable.php index bf8bf2269cfe..9a84f50870a9 100644 --- a/app/Http/Livewire/InvoicesTable.php +++ b/app/Http/Livewire/InvoicesTable.php @@ -52,6 +52,7 @@ class InvoicesTable extends Component $query = Invoice::query() ->where('company_id', $this->company->id) ->where('is_deleted', false) + ->where('is_proforma', false) ->with('client.gateway_tokens', 'client.contacts') ->orderBy($this->sort_field, $this->sort_asc ? 'asc' : 'desc'); diff --git a/app/Services/ClientPortal/InstantPayment.php b/app/Services/ClientPortal/InstantPayment.php index 2df5e3ab6974..b1136f5d605b 100644 --- a/app/Services/ClientPortal/InstantPayment.php +++ b/app/Services/ClientPortal/InstantPayment.php @@ -193,7 +193,7 @@ class InstantPayment $payment_method_id = $this->request->input('payment_method_id'); $invoice_totals = $payable_invoices->sum('amount'); $first_invoice = $invoices->first(); - $credit_totals = $first_invoice->client->getSetting('use_credits_payment') == 'always' ? $first_invoice->client->service()->getCreditBalance() : 0; + $credit_totals = in_array($first_invoice->client->getSetting('use_credits_payment'), ['always', 'option']) ? $first_invoice->client->service()->getCreditBalance() : 0; $starting_invoice_amount = $first_invoice->balance; /* Schedule a job to check the gateway fees for this invoice*/ @@ -297,7 +297,7 @@ class InstantPayment } public function processCreditPayment(Request $request, array $data) - { + { return render('gateways.credit.index', $data); } } diff --git a/app/Services/Credit/CreditService.php b/app/Services/Credit/CreditService.php index 4c88f20e81a1..db02b1127d46 100644 --- a/app/Services/Credit/CreditService.php +++ b/app/Services/Credit/CreditService.php @@ -271,11 +271,6 @@ class CreditService public function restoreCredit() { - // $this->credit->payments()->each(function ($payment){ - - // $payment->pivot->update(['deleted_at' => null]); - - // }); $this->credit ->client