From 1aba32cffc99e8e44ff80534384a8253cc044000 Mon Sep 17 00:00:00 2001 From: Joe Hunt Date: Sun, 27 Dec 2009 00:15:20 +0000 Subject: [PATCH] Problems letting various currency bank accounts sharing the same GL account Foreign currency accounts must have their own specific GL accounts. --- CHANGELOG.txt | 5 +++++ gl/manage/bank_accounts.php | 22 ++++++++++++++++++---- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index da648a26..aca7c9d2 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -19,6 +19,11 @@ Legend: ! -> Note $ -> Affected files +27-Dec-2009 Joe Hunt +# Problems letting various currency bank accounts sharing the same GL account + Foreign currency accounts must have their own specific GL accounts. +$ /gl/manage/bank_accounts.php + ------------------------------- Release 2.2.2 ---------------------------------- 23-Dec-2009 Joe Hunt ! Release 2.2.2 diff --git a/gl/manage/bank_accounts.php b/gl/manage/bank_accounts.php index ae1dc41e..97a5dbba 100644 --- a/gl/manage/bank_accounts.php +++ b/gl/manage/bank_accounts.php @@ -25,9 +25,22 @@ if ($Mode=='ADD_ITEM' || $Mode=='UPDATE_ITEM') //initialise no input errors assumed initially before we test $input_error = 0; - + $curr = get_company_currency(); + if ($curr != $_POST['BankAccountCurrency']) + { + $sql = "SELECT account_code FROM ".TB_PREF."bank_accounts + WHERE account_code = '".$_POST['account_code']."' + AND id <> $selected_id"; + $result = db_query($sql,"could not get bank accounts"); + if (db_num_rows($result) > 0) + { + $input_error = 1; + display_error(_("The GL account is already in use.")); + set_focus('account_code'); + } + } //first off validate inputs sensible - if (strlen($_POST['bank_account_name']) == 0) + if ($input_error == 0 && strlen($_POST['bank_account_name']) == 0) { $input_error = 1; display_error(_("The bank account name cannot be empty.")); @@ -190,9 +203,10 @@ else yesno_list_row(_("Default currency account:"), 'dflt_curr_act'); -if($is_editing) +$curr = get_company_currency(); +if ($is_editing && $curr == $_POST['BankAccountCurrency']) label_row(_("Bank Account GL Code:"), $_POST['account_code']); -else +else gl_all_accounts_list_row(_("Bank Account GL Code:"), 'account_code', null); text_row(_("Bank Name:"), 'bank_name', null, 50, 60); -- 2.30.2