From 5015db8f3d5ab97f6efd569c42192e248ab7baf4 Mon Sep 17 00:00:00 2001 From: Joe Hunt Date: Wed, 22 Oct 2008 09:29:58 +0000 Subject: [PATCH] Added Ending Balance in trial balance (also in report) --- CHANGELOG.txt | 8 +++++++ gl/inquiry/gl_trial_balance.php | 11 +++++++++- reporting/rep704.php | 8 +++---- reporting/rep708.php | 38 ++++++++++++++++++++++++++------- 4 files changed, 52 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index d7dddc96..389a8f9d 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -19,6 +19,14 @@ Legend: ! -> Note $ -> Affected files +22-Oct-2008 Joe Hunt ++ Added Ending Balance in trial balance (also in report) +$ /gl/inquiry/gl_trial_balance.php + /reporting/rep704.php + /reporting/rep708.php +! Bad balance in GL trans for chart en_US-demo.sql +$ /sql/en_US-demo.sql + 21-Oct-2008 Joe Hunt # Bug [0000076] Voiding Supplier Invoice does a purchase delivery void as well $ /purchasing/includes/db/invoice_db.inc diff --git a/gl/inquiry/gl_trial_balance.php b/gl/inquiry/gl_trial_balance.php index b3dee997..969cfcca 100644 --- a/gl/inquiry/gl_trial_balance.php +++ b/gl/inquiry/gl_trial_balance.php @@ -99,6 +99,7 @@ function display_trial_balance() $k = 0; + $totprev = $totcurr = 0.0; $accounts = get_gl_accounts(); while ($account = db_fetch($accounts)) @@ -108,7 +109,7 @@ function display_trial_balance() else { $begin = begin_fiscalyear(); - if ($_POST['TransFromDate'] < $begin) + if (date1_greater_date2($begin, $_POST['TransFromDate'])) $begin = $_POST['TransFromDate']; $begin = add_days($begin, -1); } @@ -117,6 +118,8 @@ function display_trial_balance() $curr_balance = get_balance($account["account_code"], $_POST['TransFromDate'], $_POST['TransToDate']); if (check_value("NoZero") && !$prev_balance && !$curr_balance) continue; + $totprev += $prev_balance; + $totcurr += $curr_balance; alt_table_row_color($k); $url = "" . $account["account_code"] . ""; @@ -129,6 +132,12 @@ function display_trial_balance() display_debit_or_credit_cells($prev_balance + $curr_balance); end_row(); } + start_row("class='inquirybg'"); + label_cell("" . _("Ending Balance") ." - ".$_POST['TransToDate']. "", "colspan=2"); + display_debit_or_credit_cells($totprev); + display_debit_or_credit_cells($totcurr); + display_debit_or_credit_cells($totprev + $totcurr); + end_row(); end_table(1); div_end(); diff --git a/reporting/rep704.php b/reporting/rep704.php index 856efecb..794b053a 100644 --- a/reporting/rep704.php +++ b/reporting/rep704.php @@ -106,10 +106,10 @@ function print_GL_transactions() $begin = ""; else { - if ($from < $begin) - $begin = add_days($from, -1); - else - $begin = add_days(begin_fiscalyear(), -1); + $begin = begin_fiscalyear(); + if (date1_greater_date2($begin, $from)) + $begin = $from; + $begin = add_days($begin, -1); } $prev_balance = get_gl_balance_from_to($begin, $from, $account["account_code"], $dimension, $dimension2); diff --git a/reporting/rep708.php b/reporting/rep708.php index cb11746c..fc71d673 100644 --- a/reporting/rep708.php +++ b/reporting/rep708.php @@ -91,6 +91,7 @@ function print_trial_balance() $rep->Font(); $rep->Info($params, $cols, $headers, $aligns, $cols2, $headers2, $aligns2); $rep->Header(); + $totprev = $totcurr = 0.0; $accounts = get_gl_accounts(); @@ -101,10 +102,10 @@ function print_trial_balance() $begin = ""; else { - if ($from < $begin) - $begin = add_days($from, -1); - else - $begin = add_days(begin_fiscalyear(), -1); + $begin = begin_fiscalyear(); + if (date1_greater_date2($begin, $from)) + $begin = $from; + $begin = add_days($begin, -1); } $prev_balance = get_gl_balance_from_to($begin, $from, $account["account_code"], $dimension, $dimension2); @@ -113,19 +114,20 @@ function print_trial_balance() if ($zero == 0 && !$prev_balance && !$curr_balance) continue; - + $totprev += $prev_balance; + $totcurr += $curr_balance; $rep->TextCol(0, 1, $account['account_code']); $rep->TextCol(1, 2, $account['account_name']); - if ($prev_balance > 0.0) + if ($prev_balance >= 0.0) $rep->TextCol(2, 3, number_format2(abs($prev_balance), $dec)); else $rep->TextCol(3, 4, number_format2(abs($prev_balance), $dec)); - if ($curr_balance > 0.0) + if ($curr_balance >= 0.0) $rep->TextCol(4, 5, number_format2(abs($curr_balance), $dec)); else $rep->TextCol(5, 6, number_format2(abs($curr_balance), $dec)); - if ($curr_balance + $prev_balance > 0.0) + if ($curr_balance + $prev_balance >= 0.0) $rep->TextCol(6, 7, number_format2(abs($curr_balance + $prev_balance), $dec)); else $rep->TextCol(7, 8, number_format2(abs($curr_balance + $prev_balance), $dec)); @@ -139,6 +141,26 @@ function print_trial_balance() } } $rep->Line($rep->row); + $rep->NewLine(); + $rep->Font('bold'); + + $rep->TextCol(0, 2, _("Ending Balance")); + + if ($totprev >= 0.0) + $rep->TextCol(2, 3, number_format2(abs($totprev), $dec)); + else + $rep->TextCol(3, 4, number_format2(abs($totprev), $dec)); + if ($totcurr >= 0.0) + $rep->TextCol(4, 5, number_format2(abs($totcurr), $dec)); + else + $rep->TextCol(5, 6, number_format2(abs($totcurr), $dec)); + if ($totcurr + $totprev >= 0.0) + $rep->TextCol(6, 7, number_format2(abs($totcurr + $totprev), $dec)); + else + $rep->TextCol(7, 8, number_format2(abs($totcurr + $totprev), $dec)); + + $rep->Line($rep->row - 6); + $rep->End(); } -- 2.30.2