From: Joe Hunt Date: Wed, 19 Dec 2018 12:22:55 +0000 (+0100) Subject: 4821: banking overdraft message has php errors. Fixed. @Braathwaathe X-Git-Url: https://delta.frontaccounting.com/gitweb/?p=fa-stable.git;a=commitdiff_plain;h=8f6852edc4c77026234c05c20235c8fe00f59631 4821: banking overdraft message has php errors. Fixed. @Braathwaathe --- diff --git a/gl/gl_bank.php b/gl/gl_bank.php index 2d446531..2d220c4f 100644 --- a/gl/gl_bank.php +++ b/gl/gl_bank.php @@ -216,7 +216,7 @@ function create_cart($type, $trans_no) function check_trans() { - global $Refs; + global $Refs, $systypes_array; $input_error = 0; @@ -244,10 +244,12 @@ function check_trans() } if ($trans = check_bank_account_history($amnt_chg, $_POST['bank_account'], $_POST['date_'])) { - display_error(sprintf(_("The bank transaction would result in exceed of authorized overdraft limit for transaction: %s #%s on %s."), - $systypes_array[$trans['type']], $trans['trans_no'], sql2date($trans['trans_date']))); - set_focus('amount'); - $input_error = 1; + if (isset($trans['trans_no'])) { + display_error(sprintf(_("The bank transaction would result in exceed of authorized overdraft limit for transaction: %s #%s on %s."), + $systypes_array[$trans['type']], $trans['trans_no'], sql2date($trans['trans_date']))); + set_focus('amount'); + $input_error = 1; + } } if (!check_reference($_POST['ref'], $_SESSION['pay_items']->trans_type, $_SESSION['pay_items']->order_id)) { diff --git a/gl/includes/db/gl_db_bank_trans.inc b/gl/includes/db/gl_db_bank_trans.inc index 5ffa2d0c..8c63f645 100644 --- a/gl/includes/db/gl_db_bank_trans.inc +++ b/gl/includes/db/gl_db_bank_trans.inc @@ -188,7 +188,7 @@ function check_bank_account_history($delta_amount, $bank_account, $date=null, $u $balance += $delta_amount; - $sql = "SELECT sum(amount) as amount, trans_date + $sql = "SELECT sum(amount) as amount, trans_date, trans_no, type FROM ".TB_PREF."bank_trans WHERE bank_act=".db_escape($bank_account); if ($date) @@ -202,7 +202,7 @@ function check_bank_account_history($delta_amount, $bank_account, $date=null, $u while ($trans = db_fetch($history)) { $balance += $trans['amount']; - if ($balance < 0) + if (round2($balance, user_price_dec()) < 0) { $trans['amount'] = $balance; return $trans;