diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index c04cb4036b86..f36399447fdd 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -2650,6 +2650,7 @@ $LANG = array( 'expired_white_label' => 'The white label license has expired', 'return_to_login' => 'Return to Login', 'convert_products_tip' => 'Note: add a custom field named ":name" to see the exchange rate.', + 'amount_greater_than_balance' => 'The amount is greater than the invoice balance, a credit will be created with the remaining amount.', ); diff --git a/resources/views/payments/edit.blade.php b/resources/views/payments/edit.blade.php index d9f612bf7fa6..ff9dc5d0e29a 100644 --- a/resources/views/payments/edit.blade.php +++ b/resources/views/payments/edit.blade.php @@ -16,7 +16,7 @@ {!! Former::open($url) ->addClass('col-lg-10 col-lg-offset-1 warn-on-exit main-form') - ->onsubmit('onFormSubmit(event)') + ->onsubmit('return onFormSubmit(event)') ->method($method) ->rules(array( 'client' => 'required', @@ -215,7 +215,17 @@ }); function onFormSubmit(event) { - $('#saveButton').attr('disabled', true); + // warn if amount is more than balance/credit will be created + var invoiceId = $('input[name=invoice]').val(); + var invoice = invoiceMap[invoiceId]; + var amount = $('#amount').val(); + + if (amount <= invoice.balance || confirm("{{ trans('texts.amount_greater_than_balance') }}")) { + $('#saveButton').attr('disabled', true); + return true; + } else { + return false; + } } function submitAction(action) {