From: Joe Hunt Date: Sun, 14 Jun 2009 10:38:01 +0000 (+0000) Subject: Much better presentation of new Balance Sheet, P&L Statement and Monthly Breakdown. X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=commitdiff_plain;h=91b4d2dedefec30e2e2c80f5f9a97c9db5d0d47a;p=textcart.git Much better presentation of new Balance Sheet, P&L Statement and Monthly Breakdown. --- diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 17d44a9..2e869c1 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -19,6 +19,14 @@ Legend: ! -> Note $ -> Affected files +14-Jun-2009 Joe Hunt +! Much better presentation of new Balance Sheet, P&L Statement and Monthly Breakdown. +$ /gl/includes/db/gl_db_account_types.inc + /gl/includes/db/gl_db_accounts.inc + /reporting/rep705.php + /reporting/rep706.php + /reporting/rep707.php + 13-Jun-2009 Joe Hunt/Pete/Tom Moulton ! Changed next reference method to also include partly alpha characters in front, fi. WA036 increments to WA037 $ /includes/references.inc diff --git a/gl/includes/db/gl_db_account_types.inc b/gl/includes/db/gl_db_account_types.inc index d731b80..ae6011c 100644 --- a/gl/includes/db/gl_db_account_types.inc +++ b/gl/includes/db/gl_db_account_types.inc @@ -100,17 +100,6 @@ function get_account_class_name($id) return $row[0]; } -function get_account_class_convert($id) -{ - global $class_types; - $sql = "SELECT balance_sheet FROM ".TB_PREF."chart_class WHERE cid = $id"; - - $result = db_query($sql, "could not get class type"); - - $row = db_fetch_row($result); - return (($row[0] == CL_LIABILITIES || $row[0] == CL_EQUITY || $row[0] == CL_INCOME || $row[0] == 0) ? -1 : 1); // backwards compatibility -} - function delete_account_class($id) { $sql = "DELETE FROM ".TB_PREF."chart_class WHERE cid = $id"; diff --git a/gl/includes/db/gl_db_accounts.inc b/gl/includes/db/gl_db_accounts.inc index bcecad7..414ad8e 100644 --- a/gl/includes/db/gl_db_accounts.inc +++ b/gl/includes/db/gl_db_accounts.inc @@ -56,7 +56,8 @@ function get_gl_accounts_all($balance=-1) elseif ($balance == 0) $where ="WHERE balance_sheet>".CL_EQUITY." OR balance_sheet=0"; // backwards compatibility $sql = "SELECT ".TB_PREF."chart_master.account_code, ".TB_PREF."chart_master.account_name, ".TB_PREF."chart_types.name AS AccountTypeName,".TB_PREF."chart_types.id AS AccountType, - ".TB_PREF."chart_types.parent, ".TB_PREF."chart_class.class_name AS AccountClassName, ".TB_PREF."chart_class.cid AS ClassID + ".TB_PREF."chart_types.parent, ".TB_PREF."chart_class.class_name AS AccountClassName, ".TB_PREF."chart_class.cid AS ClassID, + ".TB_PREF."chart_class.balance_sheet AS ClassType FROM ".TB_PREF."chart_types INNER JOIN ".TB_PREF."chart_class ON ".TB_PREF."chart_types.class_id=".TB_PREF."chart_class.cid LEFT JOIN ".TB_PREF."chart_master ON ".TB_PREF."chart_master.account_type=".TB_PREF."chart_types.id "; if ($balance != -1) diff --git a/reporting/rep705.php b/reporting/rep705.php index 341d6e5..610a82b 100644 --- a/reporting/rep705.php +++ b/reporting/rep705.php @@ -200,6 +200,7 @@ function print_annual_expense_breakdown() $closeclass = false; $convert = 1; + $ctype = 0; $accounts = get_gl_accounts_all(0); @@ -230,7 +231,7 @@ function print_annual_expense_breakdown() { for ( ; $level >= 0, $typename[$level] != ''; $level--) { - if ($account['parent'] == $closing[$level] || $account['parent'] < $last) + if ($account['parent'] == $closing[$level] || $account['parent'] < $last || $account['parent'] <= 0) { $rep->row += 6; $rep->Line($rep->row); @@ -282,8 +283,9 @@ function print_annual_expense_breakdown() $rep->Line($rep->row); $rep->NewLine(); } - $convert = get_account_class_convert($account['ClassID']); $classname = $account['AccountClassName']; + $ctype = $account['ClassType']; + $convert = (($ctype == CL_INCOME || $ctype == 0) ? -1 : 1); // backwards compatibility if ($account['account_code'] != null) { @@ -325,7 +327,7 @@ function print_annual_expense_breakdown() { for ( ; $level >= 0, $typename[$level] != ''; $level--) { - if ($account['parent'] == $closing[$level] || $account['parent'] < $last) + if ($account['parent'] == $closing[$level] || $account['parent'] < $last || $account['parent'] <= 0) { $rep->row += 6; $rep->Line($rep->row); diff --git a/reporting/rep706.php b/reporting/rep706.php index 91261cf..a8c64ec 100644 --- a/reporting/rep706.php +++ b/reporting/rep706.php @@ -112,6 +112,12 @@ function print_balance_sheet() $assetsopen = 0.0; $assetsperiod = 0.0; $assetsclose = 0.0; + $equityopen = 0.0; + $equityperiod = 0.0; + $equityclose = 0.0; + $lopen = 0.0; + $lperiod = 0.0; + $lclose = 0.0; $typeopen = array(0,0,0,0,0,0,0,0,0,0); $typeperiod = array(0,0,0,0,0,0,0,0,0,0); @@ -123,6 +129,7 @@ function print_balance_sheet() $last = -1; $closeclass = false; + $ctype = 0; $convert = 1; $rep->NewLine(); @@ -157,7 +164,7 @@ function print_balance_sheet() { for ( ; $level >= 0, $typename[$level] != ''; $level--) { - if ($account['parent'] == $closing[$level] || $account['parent'] < $last) + if ($account['parent'] == $closing[$level] || $account['parent'] < $last || $account['parent'] <= 0) { $rep->row += 6; $rep->Line($rep->row); @@ -189,6 +196,18 @@ function print_balance_sheet() $rep->AmountCol(3, 4, $classperiod * $convert, $dec); $rep->AmountCol(4, 5, $classclose * $convert, $dec); $rep->Font(); + if ($ctype == CL_EQUITY) + { + $equityopen += $classopen; + $equityperiod += $classperiod; + $equityclose += $classclose; + } + if ($ctype == CL_LIABILITIES) + { + $lopen += $classopen; + $lperiod += $classperiod; + $lclose += $classclose; + } $assetsopen += $classopen; $assetsperiod += $classperiod; $assetsclose += $classclose; @@ -215,8 +234,9 @@ function print_balance_sheet() $rep->Line($rep->row); $rep->NewLine(); } - $convert = get_account_class_convert($account['ClassID']); $classname = $account['AccountClassName']; + $ctype = $account['ClassType']; + $convert = (($ctype == CL_LIABILITIES || $ctype == CL_EQUITY || $ctype == 0) ? -1 : 1); // backwards compatibility if ($account['account_code'] != null) { @@ -254,11 +274,14 @@ function print_balance_sheet() } if ($account['AccountTypeName'] != $typename[$level]) { + //$rep->NewLine(); + //$rep->TextCol(0, 5, "type = ".$account['AccountType'].", level = $level, closing[0]-[1]-[2]-[3] = ".$closing[0]." ".$closing[1]." ".$closing[2]." ".$closing[3]." type[parent] = ".$account['parent']." last = ".$last); + //$rep->NewLine(); if ($typename[$level] != '') { for ( ; $level >= 0, $typename[$level] != ''; $level--) { - if ($account['parent'] == $closing[$level] || $account['parent'] < $last) + if ($account['parent'] == $closing[$level] || $account['parent'] < $last || $account['parent'] <= 0) { $rep->row += 6; $rep->Line($rep->row); @@ -284,6 +307,12 @@ function print_balance_sheet() $calculateopen = -$assetsopen - $classopen; $calculateperiod = -$assetsperiod - $classperiod; $calculateclose = -$assetsclose - $classclose; + if ($ctype == CL_EQUITY) + { + $equityopen += $classopen; + $equityperiod += $classperiod; + $equityclose += $classclose; + } $rep->row += 6; $rep->Line($rep->row); $rep->NewLine(); @@ -302,8 +331,19 @@ function print_balance_sheet() $rep->AmountCol(2, 3, -$assetsopen * $convert, $dec); $rep->AmountCol(3, 4, -$assetsperiod * $convert, $dec); $rep->AmountCol(4, 5, -$assetsclose * $convert, $dec); - $rep->Font(); $rep->NewLine(); + if ($equityopen != 0.0 || $equityperiod != 0.0 || $equityclose != 0.0 || + $lopen != 0.0 || $lperiod != 0.0 || $lclose != 0.0) + { + $rep->NewLine(); + $rep->TextCol(0, 2, _('Total') . " " . _('Liabilities') . _(' and ') . _('Equities')); + $rep->AmountCol(2, 3, ($lopen + $equityopen + $calculateopen) * -1, $dec); + $rep->AmountCol(3, 4, ($lperiod + $equityperiod + $calculateperiod) * -1, $dec); + $rep->AmountCol(4, 5, ($lclose + $equityclose + $calculateclose) * -1, $dec); + $rep->Font(); + $rep->NewLine(); + } + $rep->Font(); } } } diff --git a/reporting/rep707.php b/reporting/rep707.php index df551fc..7ce02b2 100644 --- a/reporting/rep707.php +++ b/reporting/rep707.php @@ -156,6 +156,7 @@ function print_profit_and_loss_statement() $closeclass = false; $convert = 1; + $ctype = 0; $accounts = get_gl_accounts_all(0); @@ -190,7 +191,7 @@ function print_profit_and_loss_statement() { for ( ; $level >= 0, $typename[$level] != ''; $level--) { - if ($account['parent'] == $closing[$level] || $account['parent'] < $last) + if ($account['parent'] == $closing[$level] || $account['parent'] < $last || $account['parent'] <= 0) { $rep->row += 6; $rep->Line($rep->row); @@ -248,8 +249,9 @@ function print_profit_and_loss_statement() $rep->Line($rep->row); $rep->NewLine(); } - $convert = get_account_class_convert($account['ClassID']); $classname = $account['AccountClassName']; + $ctype = $account['ClassType']; + $convert = (($ctype == CL_INCOME || $ctype == 0) ? -1 : 1); // backwards compatibility if ($account['account_code'] != null) { @@ -292,7 +294,7 @@ function print_profit_and_loss_statement() { for ( ; $level >= 0, $typename[$level] != ''; $level--) { - if ($account['parent'] == $closing[$level] || $account['parent'] < $last) + if ($account['parent'] == $closing[$level] || $account['parent'] < $last || $account['parent'] <= 0) { $rep->row += 6; $rep->Line($rep->row);