+ if (input_num('amount') == 0) {
+ display_error(_("The total bank amount cannot be 0."));
+ set_focus('amount');
+ return false;
+ }
+
+ $limit = get_bank_account_limit($_POST['FromBankAccount'], $_POST['DatePaid']);
+
+ $amnt_tr = input_num('charge') + input_num('amount');
+
+ $problemTransaction = null;
+ if ($trans_no) {
+ $problemTransaction = check_bank_transfer( $trans_no, $_POST['FromBankAccount'], $_POST['ToBankAccount'], $_POST['DatePaid'],
+ $amnt_tr, input_num('target_amount', $amnt_tr));
+
+ if ($problemTransaction != null ) {
+ if (!array_key_exists('trans_no', $problemTransaction)) {
+ display_error(sprintf(
+ _("This bank transfer change would result in exceeding authorized overdraft limit (%s) of the account '%s'"),
+ price_format(-$problemTransaction['amount']), $problemTransaction['bank_account_name']
+ ));
+ } else {
+ display_error(sprintf(
+ _("This bank transfer change would result in exceeding authorized overdraft limit on '%s' for transaction: %s #%s on %s."),
+ $problemTransaction['bank_account_name'], $systypes_array[$problemTransaction['type']],
+ $problemTransaction['trans_no'], sql2date($problemTransaction['trans_date'])
+ ));
+ }
+ set_focus('amount');
+ return false;
+ }
+ } else {
+ if (null != ($problemTransaction = check_bank_account_history(-$amnt_tr, $_POST['FromBankAccount'], $_POST['DatePaid']))) {
+ if (!array_key_exists('trans_no', $problemTransaction)) {
+ display_error(sprintf(
+ _("This bank transfer would result in exceeding authorized overdraft limit of the account (%s)"),
+ price_format(-$problemTransaction['amount'])
+ ));
+ } else {
+ display_error(sprintf(
+ _("This bank transfer would result in exceeding authorized overdraft limit for transaction: %s #%s on %s."),
+ $systypes_array[$problemTransaction['type']], $problemTransaction['trans_no'], sql2date($problemTransaction['trans_date'])
+ ));
+ }
+ set_focus('amount');
+ return false;
+ }
+ }