From: Joe Hunt Date: Fri, 1 Jul 2011 21:25:24 +0000 (+0200) Subject: 0000918: GL Inquiry, trial balance for a non-balance account for non-current year... X-Git-Tag: 2.3-final~608 X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=commitdiff_plain;h=c2d46f57e3b3becc9dceaa02a43cf85fd8c8789a;p=fa-stable.git 0000918: GL Inquiry, trial balance for a non-balance account for non-current year shows 0 --- diff --git a/admin/db/fiscalyears_db.inc b/admin/db/fiscalyears_db.inc index b14ce5ba..a3133c93 100644 --- a/admin/db/fiscalyears_db.inc +++ b/admin/db/fiscalyears_db.inc @@ -81,6 +81,18 @@ function is_date_in_fiscalyears($date, $closed=true) return db_fetch($result) !== false; } +function get_fiscalyear_begin_for_date($date) +{ + $date = date2sql($date); + $sql = "SELECT begin FROM ".TB_PREF."fiscal_year WHERE '$date' >= begin AND '$date' <= end"; + $result = db_query($sql, "could not get begin date of the fiscal year"); + $row = db_fetch_row($result); + if ($row != false) + return sql2date($row[0]); + else + return begin_fiscalyear(); +} + function check_begin_end_date($date1, $date2) { $sql = "SELECT MAX(end), MIN(begin) FROM ".TB_PREF."fiscal_year"; diff --git a/gl/inquiry/gl_account_inquiry.php b/gl/inquiry/gl_account_inquiry.php index 5bef33f9..9aff2365 100644 --- a/gl/inquiry/gl_account_inquiry.php +++ b/gl/inquiry/gl_account_inquiry.php @@ -14,6 +14,7 @@ $path_to_root = "../.."; include_once($path_to_root . "/includes/session.inc"); +include_once($path_to_root . "/admin/db/fiscalyears_db.inc"); include_once($path_to_root . "/includes/date_functions.inc"); include_once($path_to_root . "/includes/ui.inc"); include_once($path_to_root . "/includes/data_checks.inc"); @@ -148,7 +149,7 @@ function show_results() $begin = ""; else { - $begin = begin_fiscalyear(); + $begin = get_fiscalyear_begin_for_date($_POST['TransFromDate']); if (date1_greater_date2($begin, $_POST['TransFromDate'])) $begin = $_POST['TransFromDate']; $begin = add_days($begin, -1); diff --git a/gl/inquiry/gl_trial_balance.php b/gl/inquiry/gl_trial_balance.php index 12aa2324..53738843 100644 --- a/gl/inquiry/gl_trial_balance.php +++ b/gl/inquiry/gl_trial_balance.php @@ -75,7 +75,8 @@ function display_trial_balance($type, $typename) //Get Accounts directly under this group/type $accounts = get_gl_accounts(null, null, $type); - $begin = begin_fiscalyear(); + $begin = get_fiscalyear_begin_for_date($_POST['TransFromDate']); + //$begin = begin_fiscalyear(); if (date1_greater_date2($begin, $_POST['TransFromDate'])) $begin = $_POST['TransFromDate']; $begin = add_days($begin, -1); diff --git a/reporting/rep704.php b/reporting/rep704.php index 08391fbd..e8063a82 100644 --- a/reporting/rep704.php +++ b/reporting/rep704.php @@ -19,6 +19,7 @@ $page_security = 'SA_GLREP'; $path_to_root=".."; include_once($path_to_root . "/includes/session.inc"); +include_once($path_to_root . "/admin/db/fiscalyears_db.inc"); include_once($path_to_root . "/includes/date_functions.inc"); include_once($path_to_root . "/includes/data_checks.inc"); include_once($path_to_root . "/gl/includes/gl_db.inc"); @@ -121,7 +122,7 @@ function print_GL_transactions() $begin = ""; else { - $begin = begin_fiscalyear(); + $begin = get_fiscalyear_begin_for_date($from); if (date1_greater_date2($begin, $from)) $begin = $from; $begin = add_days($begin, -1); diff --git a/reporting/rep708.php b/reporting/rep708.php index e57d0a9f..979ca2e1 100644 --- a/reporting/rep708.php +++ b/reporting/rep708.php @@ -19,6 +19,7 @@ $page_security = 'SA_GLANALYTIC'; $path_to_root=".."; include_once($path_to_root . "/includes/session.inc"); +include_once($path_to_root . "/admin/db/fiscalyears_db.inc"); include_once($path_to_root . "/includes/ui.inc"); include_once($path_to_root . "/includes/date_functions.inc"); include_once($path_to_root . "/includes/data_checks.inc"); @@ -37,7 +38,7 @@ function display_type ($type, $typename, &$dec, &$rep, $from, $to, $zero, $balan //Get Accounts directly under this group/type $accounts = get_gl_accounts(null, null, $type); - $begin = begin_fiscalyear(); + $begin = get_fiscalyear_begin_for_date($from); if (date1_greater_date2($begin, $from)) $begin = $from; $begin = add_days($begin, -1);