diff --git a/app/Http/ValidationRules/Credit/ValidCreditsRules.php b/app/Http/ValidationRules/Credit/ValidCreditsRules.php index f745092fe967..b8d6d2624ed8 100644 --- a/app/Http/ValidationRules/Credit/ValidCreditsRules.php +++ b/app/Http/ValidationRules/Credit/ValidCreditsRules.php @@ -51,6 +51,15 @@ class ValidCreditsRules implements Rule $unique_array = []; + $total_credit_amount = array_sum(array_column($this->input['credits'], 'amount')); + + if($total_credit_amount <= 0){ + + $this->error_msg = "Total of credits must be more than zero."; + + return false; + } + $cred_collection = Credit::withTrashed()->whereIn('id', array_column($this->input['credits'], 'credit_id'))->get(); foreach ($this->input['credits'] as $credit) { diff --git a/app/Services/ClientPortal/InstantPayment.php b/app/Services/ClientPortal/InstantPayment.php index 9ab3dc581e1e..9d03393b2e59 100644 --- a/app/Services/ClientPortal/InstantPayment.php +++ b/app/Services/ClientPortal/InstantPayment.php @@ -48,6 +48,7 @@ class InstantPayment public function run() { + $is_credit_payment = false; $tokens = []; @@ -107,6 +108,7 @@ class InstantPayment $payable_amount = Number::roundValue(Number::parseFloat($payable_invoice['amount'], $client->currency()->precision)); $invoice_balance = Number::roundValue(($invoice->partial > 0 ? $invoice->partial : $invoice->balance), $client->currency()->precision); + /*If we don't allow under/over payments force the payable amount - prevents inspect element adjustments in JS*/ if ($settings->client_portal_allow_under_payment == false && $settings->client_portal_allow_over_payment == false) {