2 /**********************************************************************
3 Copyright (C) FrontAccounting, LLC.
4 Released under the terms of the GNU Affero General Public License,
5 AGPL, as published by the Free Software Foundation, either version
6 3 of the License, or (at your option) any later version.
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 See the License here <http://www.gnu.org/licenses/agpl-3.0.html>.
11 ***********************************************************************/
12 include_once($path_to_root . "/gl/includes/gl_db.inc");
14 function validate_bank_trans()
16 dump_msg("<b>Checking bank transactions.........</b>");
18 // check that the account in the trans is actually a P/L account
19 $sql = "SELECT * FROM ".TB_PREF."bank_trans,".TB_PREF."chart_master, ".TB_PREF."chart_types
20 WHERE ".TB_PREF."bank_trans.bank_act=".TB_PREF."chart_master.account_code
21 AND ".TB_PREF."chart_master.account_type=".TB_PREF."chart_types.id
22 AND (".TB_PREF."chart_types.class_id = 1 OR ".TB_PREF."chart_types.class_id = 2)";
24 $result = db_query($sql);
25 if (db_num_rows($result) > 0)
27 dump_msg("There are bank transactions with accounts that are not Profit&Loss");
30 $sql = "SELECT * FROM ".TB_PREF."bank_trans";
31 $result = db_query($sql);
32 while ($banktrans = db_fetch($result))
34 // make sure bank_act is valid
35 $get = get_gl_account($banktrans["bank_act"]);
37 dump_msg("Invalid Bank Account for bank trans " . $banktrans["id"]);
39 // make sure the type is valid
40 $get = get_bank_trans_type($banktrans["bank_trans_type_id"]);
42 dump_msg("Invalid bank_trans_type_id (" . $banktrans["bank_trans_type_id"] . ") for bank_trans " . $banktrans["id"]);
44 if ($banktrans["type"] != 1 && $banktrans["type"] != 2 && $banktrans["type"] != 4
45 && $banktrans["type"] != 22 && $banktrans["type"] != 12)
46 dump_msg("Invalid type for bank_trans " . $banktrans["id"]);