diff --git a/app/Console/Commands/CheckData.php b/app/Console/Commands/CheckData.php index a793a593bf40..4f522262d093 100644 --- a/app/Console/Commands/CheckData.php +++ b/app/Console/Commands/CheckData.php @@ -185,6 +185,9 @@ class CheckData extends Command if ($cu->company && $cu->user) { (new CreateCompanyToken($cu->company, $cu->user, 'System'))->handle(); } + else { + // $cu->forceDelete(); + } } }); } diff --git a/app/Services/ClientPortal/InstantPayment.php b/app/Services/ClientPortal/InstantPayment.php index 9d0de18ac540..a23dd2ee4d13 100644 --- a/app/Services/ClientPortal/InstantPayment.php +++ b/app/Services/ClientPortal/InstantPayment.php @@ -273,7 +273,7 @@ class InstantPayment 'is_recurring' => $this->request->is_recurring, ]; - if ($is_credit_payment || $totals <= 0) { + if ($is_credit_payment) { return $this->processCreditPayment($this->request, $data); } diff --git a/app/Services/Payment/RefundPayment.php b/app/Services/Payment/RefundPayment.php index 15952fe8733c..fe56ef089145 100644 --- a/app/Services/Payment/RefundPayment.php +++ b/app/Services/Payment/RefundPayment.php @@ -238,7 +238,8 @@ class RefundPayment private function adjustInvoices() { if (isset($this->refund_data['invoices']) && count($this->refund_data['invoices']) > 0) { - foreach ($this->refund_data['invoices'] as $refunded_invoice) { + foreach ($this->refund_data['invoices'] as $refunded_invoice) + { $invoice = Invoice::withTrashed()->find($refunded_invoice['invoice_id']); if ($invoice->trashed()) { @@ -265,10 +266,10 @@ class RefundPayment $invoice->saveQuietly(); - //06-09-2022 + //08-08-2023 $client = $invoice->client ->service() - ->updateBalance($refunded_invoice['amount']) + ->updateBalanceAndPaidToDate($refunded_invoice['amount'], -1 * $refunded_invoice['amount']) ->save(); if ($invoice->is_deleted) { @@ -276,13 +277,6 @@ class RefundPayment } } - $client = $this->payment->client->fresh(); - - if ($client->trashed()) { - $client->restore(); - } - - $client->service()->updatePaidToDate(-1 * $refunded_invoice['amount'])->save(); } else { //if we are refunding and no payments have been tagged, then we need to decrement the client->paid_to_date by the total refund amount.