Problems letting various currency bank accounts sharing the same GL account
authorJoe Hunt <joe.hunt.consulting@gmail.com>
Sun, 27 Dec 2009 00:15:20 +0000 (00:15 +0000)
committerJoe Hunt <joe.hunt.consulting@gmail.com>
Sun, 27 Dec 2009 00:15:20 +0000 (00:15 +0000)
Foreign currency accounts must have their own specific GL accounts.

CHANGELOG.txt
gl/manage/bank_accounts.php

index da648a26a52355a7c35411db76461e113e9d876d..aca7c9d2683dc267c2d94f879a15f17cedc2fba1 100644 (file)
@@ -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
index ae1dc41e6f8cc7e924b4a1bc0ef88397afa17286..97a5dbba252aad596f8e5a37efe76245860f0d9a 100644 (file)
@@ -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);