0000918: GL Inquiry, trial balance for a non-balance account for non-current year...
authorJoe Hunt <joe.hunt.consulting@gmail.com>
Fri, 1 Jul 2011 21:25:24 +0000 (23:25 +0200)
committerJoe Hunt <joe.hunt.consulting@gmail.com>
Fri, 1 Jul 2011 21:25:24 +0000 (23:25 +0200)
admin/db/fiscalyears_db.inc
gl/inquiry/gl_account_inquiry.php
gl/inquiry/gl_trial_balance.php
reporting/rep704.php
reporting/rep708.php

index b14ce5bad49527f0579292e92d545c9c6bf5cef7..a3133c933a46c54f8f2d8012526b47d20a9b5e92 100644 (file)
@@ -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";
index 5bef33f95079912195fd7871f88232e8408f561c..9aff2365ac093c3c9d50d8c1d315100e4ad847bc 100644 (file)
@@ -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);
index 12aa232445eb8404c49d476992d4877348d43b22..53738843364d6462b6227b6ba5018933363bff8e 100644 (file)
@@ -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);
index 08391fbd07b51c491c9d0b1495c0340cf50f5c77..e8063a82a1d7174284d1355ee1ff08c713e64235 100644 (file)
@@ -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);
index e57d0a9f7265860fa0908b758454aadc52ff6e9c..979ca2e1e4a45bffa0d9e871a8627e209f11b8b7 100644 (file)
@@ -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);