mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 13:12:50 +01:00
Prevent negative credits from being applied as payments to a invoice
This commit is contained in:
parent
9edf9a599e
commit
496da291d8
@ -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) {
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user