4821: banking overdraft message has php errors. Fixed. @Braathwaathe
authorJoe Hunt <joe.hunt.consulting@gmail.com>
Wed, 19 Dec 2018 12:22:55 +0000 (13:22 +0100)
committerJoe Hunt <joe.hunt.consulting@gmail.com>
Wed, 19 Dec 2018 12:22:55 +0000 (13:22 +0100)
gl/gl_bank.php
gl/includes/db/gl_db_bank_trans.inc

index 2d44653179c3e0e72c54c914a610f727a0663081..2d220c4fd25fbca9bfa4a2b19eb580ba54cd1bec 100644 (file)
@@ -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))
        {
index 5ffa2d0cf0acd52f8f5eabead63a537971f4abe9..8c63f64573bf3bdfd5ac7f1f1e76a22d7177c5d4 100644 (file)
@@ -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;