From 43d920dc416c7c8716c98753dc75309f844565d0 Mon Sep 17 00:00:00 2001 From: Janusz Dobrowolski Date: Mon, 27 Dec 2010 13:09:58 +0000 Subject: [PATCH] [0000297] Added balance limit check on payments made from cash type accounts. --- CHANGELOG.txt | 6 +++++- gl/gl_bank.php | 11 ++++++++++- gl/includes/db/gl_db_bank_accounts.inc | 15 +++++++++++++++ purchasing/supplier_payment.php | 10 ++++++++++ 4 files changed, 40 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index bc04468..029cd46 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -19,7 +19,7 @@ Legend: ! -> Note $ -> Affected files -2-Dec-2010 Janusz Dobrowolski +27-Dec-2010 Janusz Dobrowolski + Option for allowing negative prices for dummy/service items [0000343] $ /config.default.php /sales/sales_order_entry.php @@ -27,6 +27,10 @@ $ /config.default.php $ /admin/db/transactions_db.inc # [0000380] Database error during direct invoice processing in mysql strict mode. $ /sales/includes/db/cust_trans_db.inc +! Added balance limit for payments made from cash accounts +$ /gl/gl_bank.php + /gl/includes/db/gl_db_bank_accounts.inc + /purchasing/supplier_payment.php 19-Dec-2010 Janusz Dobrowolski # Supressed strict warnings in reporting diff --git a/gl/gl_bank.php b/gl/gl_bank.php index 5ed202e..8dd950f 100644 --- a/gl/gl_bank.php +++ b/gl/gl_bank.php @@ -224,6 +224,15 @@ if (isset($_POST['Process'])) $input_error = 1; } + $limit = get_bank_account_limit($_POST['bank_account'], $_POST['date_']); + + if ($limit != null && ($limit < $_SESSION['pay_items']->gl_items_total())) + { + display_error(sprintf(_("The total bank amount exceeds allowed limit (%s)."), price_format($limit))); + set_focus('code_id'); + $input_error = 1; + } + if (!$Refs->is_valid($_POST['ref'])) { display_error( _("You must enter a reference.")); @@ -247,7 +256,7 @@ if (isset($_POST['Process'])) display_error(_("The entered date is not in fiscal year.")); set_focus('date_'); $input_error = 1; - } + } if (get_post('PayType')==PT_CUSTOMER && (!get_post('person_id') || !get_post('PersonDetailID'))) { display_error(_("You have to select customer and customer branch.")); diff --git a/gl/includes/db/gl_db_bank_accounts.inc b/gl/includes/db/gl_db_bank_accounts.inc index 7f46f62..3e88676 100644 --- a/gl/includes/db/gl_db_bank_accounts.inc +++ b/gl/includes/db/gl_db_bank_accounts.inc @@ -315,4 +315,19 @@ function get_default_bank_account($curr) return db_fetch($result); } +//--------------------------------------------------------------------------------------------- +// +// This function returns current allowed bank payment limit, or null if limit is not set. +// As of FA 2.3 check is done only on cash account, for which limit is bank amount as of the date selected. +// +function get_bank_account_limit($account, $date, $user=null) +{ +// $user = current_user(); + + $bankacc = get_bank_account($account); + if ($bankacc['account_type'] != BT_CASH) + return null; + return get_balance_before_for_bank_account($account, $date); +} + ?> \ No newline at end of file diff --git a/purchasing/supplier_payment.php b/purchasing/supplier_payment.php index 0d094ba..5421ee4 100644 --- a/purchasing/supplier_payment.php +++ b/purchasing/supplier_payment.php @@ -186,6 +186,16 @@ function check_inputs() set_focus('DatePaid'); return false; } + + $limit = get_bank_account_limit($_POST['bank_account'], $_POST['DatePaid']); + + if ($limit != null && ($limit < input_num('amount'))) + { + display_error(sprintf(_("The total bank amount exceeds allowed limit (%s)."), price_format($limit))); + set_focus('amount'); + return false; + } + if (!$Refs->is_valid($_POST['ref'])) { display_error(_("You must enter a reference.")); -- 2.30.2