From 213a86c836921f05619f81173cd4807fdcef71a2 Mon Sep 17 00:00:00 2001 From: Janusz Dobrowolski Date: Thu, 31 Mar 2011 10:36:19 +0200 Subject: [PATCH] [0000695] Problem with cash balance constraint during payment edition fixed. --- gl/gl_bank.php | 8 ++++---- includes/ui/items_cart.inc | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/gl/gl_bank.php b/gl/gl_bank.php index f8303016..8ad2aabf 100644 --- a/gl/gl_bank.php +++ b/gl/gl_bank.php @@ -172,7 +172,7 @@ function create_cart($type, $trans_no) $cart->tran_date = sql2date($bank_trans['trans_date']); $cart->reference = $Refs->get($type, $trans_no); - $gl_amount = 0; + $cart->original_amount = $bank_trans['amount']; $result = get_gl_trans($type, $trans_no); if ($result) { while ($row = db_fetch($result)) { @@ -184,10 +184,10 @@ function create_cart($type, $trans_no) $date = $row['tran_date']; $cart->add_gl_item( $row['account'], $row['dimension_id'], $row['dimension2_id'], $row['amount'], $row['memo_']); - $gl_amount += $row['amount']; } } } + // apply exchange rate foreach($cart->gl_items as $line_no => $line) $cart->gl_items[$line_no]->amount *= $ex_rate; @@ -226,9 +226,9 @@ if (isset($_POST['Process'])) $limit = get_bank_account_limit($_POST['bank_account'], $_POST['date_']); - if ($limit != null && ($limit < $_SESSION['pay_items']->gl_items_total())) + if ($limit != null && (($limit - $_SESSION['pay_items']->original_amount) < $_SESSION['pay_items']->gl_items_total())) { - display_error(sprintf(_("The total bank amount exceeds allowed limit (%s)."), price_format($limit))); + display_error(sprintf(_("The total bank amount exceeds allowed limit (%s)."), price_format($limit-$_SESSION['pay_items']->original_amount))); set_focus('code_id'); $input_error = 1; } diff --git a/includes/ui/items_cart.inc b/includes/ui/items_cart.inc index f619bbca..53a99421 100644 --- a/includes/ui/items_cart.inc +++ b/includes/ui/items_cart.inc @@ -31,6 +31,7 @@ class items_cart var $person_id; var $branch_id; var $reference; + var $original_amount; function items_cart($type) { -- 2.30.2