From: Joe Hunt Date: Fri, 12 Jun 2009 08:48:32 +0000 (+0000) Subject: Code clean-up X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=commitdiff_plain;h=fec74891c6e346cbc955ad4005c1f7cb4987ae93;p=textcart.git Code clean-up --- diff --git a/CHANGELOG.txt b/CHANGELOG.txt index ee629ad..00d347d 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -19,6 +19,13 @@ Legend: ! -> Note $ -> Affected files +12-Jun-2009 Joe Hunt +! Code clean-up +$ /gl/includes/db/gl_db_trans.inc + /gl/inquiry/gl_trial_balance.php + /includes/ui/ui_view.inc + /reporting/rep708.php + 11-Jun-2009 Joe Hunt ! Changed balance_sheet operation in class table to class type for sign convert in Balance Sheet, Profit and Loss Statement and Monthly Breakdown $ /gl/manage/gl_account_classes.php @@ -26,6 +33,7 @@ $ /gl/manage/gl_account_classes.php /gl/includes/db/gl_db_accounts.inc /gl/inquiry/gl_trial_balance.php /includes/types.inc + /includes/ui/ui_lists.inc /reporting/rep705.php /reporting/rep706.php /reporting/rep707.php diff --git a/gl/includes/db/gl_db_trans.inc b/gl/includes/db/gl_db_trans.inc index 3570f9c..76d293e 100644 --- a/gl/includes/db/gl_db_trans.inc +++ b/gl/includes/db/gl_db_trans.inc @@ -197,6 +197,36 @@ function get_gl_trans_from_to($from_date, $to_date, $account, $dimension=0, $dim return $row[0]; } +//---------------------------------------------------------------------------------------------------- +function get_balance($account, $dimension, $dimension2, $from, $to, $from_incl=true, $to_incl=true) +{ + $sql = "SELECT SUM(IF(amount >= 0, amount, 0)) as debit, SUM(IF(amount < 0, -amount, 0)) as credit, SUM(amount) as balance + FROM ".TB_PREF."gl_trans,".TB_PREF."chart_master,".TB_PREF."chart_types, ".TB_PREF."chart_class + WHERE ".TB_PREF."gl_trans.account=".TB_PREF."chart_master.account_code AND ".TB_PREF."chart_master.account_type=".TB_PREF."chart_types.id + AND ".TB_PREF."chart_types.class_id=".TB_PREF."chart_class.cid AND"; + + if ($account != null) + $sql .= " account='$account' AND"; + if ($dimension > 0) + $sql .= " dimension_id=$dimension AND"; + if ($dimension2 > 0) + $sql .= " dimension2_id=$dimension2 AND"; + $from_date = date2sql($from); + if ($from_incl) + $sql .= " tran_date >= '$from_date' AND"; + else + $sql .= " tran_date > IF(balance_sheet>0 AND balance_sheet<".CL_INCOME.", '0000-00-00', '$from_date') AND"; + $to_date = date2sql($to); + if ($to_incl) + $sql .= " tran_date <= '$to_date' "; + else + $sql .= " tran_date < '$to_date' "; + + $result = db_query($sql,"No general ledger accounts were returned"); + + return db_fetch($result); +} + //-------------------------------------------------------------------------------- function get_budget_trans_from_to($from_date, $to_date, $account, $dimension=0, $dimension2=0) diff --git a/gl/inquiry/gl_trial_balance.php b/gl/inquiry/gl_trial_balance.php index 6d33b98..6bf807c 100644 --- a/gl/inquiry/gl_trial_balance.php +++ b/gl/inquiry/gl_trial_balance.php @@ -53,33 +53,6 @@ function gl_inquiry_controls() //---------------------------------------------------------------------------------------------------- -function get_balance($account, $from, $to, $from_incl=true, $to_incl=true) -{ - $sql = "SELECT SUM(IF(amount >= 0, amount, 0)) AS debit, SUM(IF(amount < 0, -amount, 0)) AS credit, SUM(amount) AS balance - FROM ".TB_PREF."gl_trans,".TB_PREF."chart_master,".TB_PREF."chart_types, ".TB_PREF."chart_class - WHERE ".TB_PREF."gl_trans.account=".TB_PREF."chart_master.account_code AND ".TB_PREF."chart_master.account_type=".TB_PREF."chart_types.id - AND ".TB_PREF."chart_types.class_id=".TB_PREF."chart_class.cid AND"; - - if ($account != null) - $sql .= " account='$account' AND"; - $from_date = date2sql($from); - if ($from_incl) - $sql .= " tran_date >= '$from_date' AND"; - else - $sql .= " tran_date > IF(balance_sheet>0 AND balance_sheet<".CL_INCOME.", '0000-00-00', '$from_date') AND"; - $to_date = date2sql($to); - if ($to_incl) - $sql .= " tran_date <= '$to_date' "; - else - $sql .= " tran_date < '$to_date' "; - - $result = db_query($sql,"No general ledger accounts were returned"); - - return db_fetch($result); -} - -//---------------------------------------------------------------------------------------------------- - function display_trial_balance() { global $table_style, $path_to_root; @@ -114,9 +87,9 @@ function display_trial_balance() while ($account = db_fetch($accounts)) { - $prev = get_balance($account["account_code"], $begin, $_POST['TransFromDate'], false, false); - $curr = get_balance($account["account_code"], $_POST['TransFromDate'], $_POST['TransToDate'], true, true); - $tot = get_balance($account["account_code"], $begin, $_POST['TransToDate'], false, true); + $prev = get_balance($account["account_code"], 0, 0, $begin, $_POST['TransFromDate'], false, false); + $curr = get_balance($account["account_code"], 0, 0, $_POST['TransFromDate'], $_POST['TransToDate'], true, true); + $tot = get_balance($account["account_code"], 0, 0, $begin, $_POST['TransToDate'], false, true); if (check_value("NoZero") && !$prev['balance'] && !$curr['balance'] && !$tot['balance']) continue; alt_table_row_color($k); diff --git a/includes/ui/ui_view.inc b/includes/ui/ui_view.inc index a1fb09f..e978b36 100644 --- a/includes/ui/ui_view.inc +++ b/includes/ui/ui_view.inc @@ -401,7 +401,7 @@ function view_stock_status_cell($stock_id, $description=null) function display_debit_or_credit_cells($value) { - if ($value > 0) + if ($value >= 0) { amount_cell($value); label_cell(""); @@ -411,12 +411,6 @@ function display_debit_or_credit_cells($value) label_cell(""); amount_cell(abs($value)); } - else - { - //label_cell(""); - amount_cell(0); - label_cell(""); - } } //-------------------------------------------------------------------------------------- diff --git a/reporting/rep708.php b/reporting/rep708.php index f46cba8..dd02718 100644 --- a/reporting/rep708.php +++ b/reporting/rep708.php @@ -27,36 +27,6 @@ include_once($path_to_root . "/gl/includes/gl_db.inc"); print_trial_balance(); -//---------------------------------------------------------------------------------------------------- -function get_balance($account, $dimension, $dimension2, $from, $to, $from_incl=true, $to_incl=true) -{ - $sql = "SELECT SUM(IF(amount >= 0, amount, 0)) as debit, SUM(IF(amount < 0, -amount, 0)) as credit, SUM(amount) as balance - FROM ".TB_PREF."gl_trans,".TB_PREF."chart_master,".TB_PREF."chart_types, ".TB_PREF."chart_class - WHERE ".TB_PREF."gl_trans.account=".TB_PREF."chart_master.account_code AND ".TB_PREF."chart_master.account_type=".TB_PREF."chart_types.id - AND ".TB_PREF."chart_types.class_id=".TB_PREF."chart_class.cid AND"; - - if ($account != null) - $sql .= " account='$account' AND"; - if ($dimension > 0) - $sql .= " dimension_id=$dimension AND"; - if ($dimension2 > 0) - $sql .= " dimension2_id=$dimension2 AND"; - $from_date = date2sql($from); - if ($from_incl) - $sql .= " tran_date >= '$from_date' AND"; - else - $sql .= " tran_date > IF(balance_sheet>0 AND balance_sheet<".CL_INCOME.", '0000-00-00', '$from_date') AND"; - $to_date = date2sql($to); - if ($to_incl) - $sql .= " tran_date <= '$to_date' "; - else - $sql .= " tran_date < '$to_date' "; - - $result = db_query($sql,"No general ledger accounts were returned"); - - return db_fetch($result); -} - //---------------------------------------------------------------------------------------------------- function print_trial_balance() diff --git a/sql/en_US-demo.sql b/sql/en_US-demo.sql index 8b80ee2..028d4b4 100644 --- a/sql/en_US-demo.sql +++ b/sql/en_US-demo.sql @@ -187,10 +187,10 @@ CREATE TABLE `0_chart_class` ( ### Data of table `0_chart_class` ### INSERT INTO `0_chart_class` VALUES ('1', 'Assets', '1'); -INSERT INTO `0_chart_class` VALUES ('2', 'Liabilities', '1'); -INSERT INTO `0_chart_class` VALUES ('3', 'Income', '0'); -INSERT INTO `0_chart_class` VALUES ('4', 'Costs', '0'); -INSERT INTO `0_chart_class` VALUES ('5', 'Gross', '0'); +INSERT INTO `0_chart_class` VALUES ('2', 'Liabilities', '2'); +INSERT INTO `0_chart_class` VALUES ('3', 'Income', '4'); +INSERT INTO `0_chart_class` VALUES ('4', 'Costs', '6'); +INSERT INTO `0_chart_class` VALUES ('5', 'Gross', '6'); ### Structure of table `0_chart_master` ### diff --git a/sql/en_US-new.sql b/sql/en_US-new.sql index cda5540..3821c78 100644 --- a/sql/en_US-new.sql +++ b/sql/en_US-new.sql @@ -168,9 +168,9 @@ CREATE TABLE `0_chart_class` ( ### Data of table `0_chart_class` ### INSERT INTO `0_chart_class` VALUES ('1', 'Assets', '1'); -INSERT INTO `0_chart_class` VALUES ('2', 'Liabilities', '1'); -INSERT INTO `0_chart_class` VALUES ('3', 'Income', '0'); -INSERT INTO `0_chart_class` VALUES ('4', 'Costs', '0'); +INSERT INTO `0_chart_class` VALUES ('2', 'Liabilities', '2'); +INSERT INTO `0_chart_class` VALUES ('3', 'Income', '4'); +INSERT INTO `0_chart_class` VALUES ('4', 'Costs', '6'); ### Structure of table `0_chart_master` ### diff --git a/update.html b/update.html index 5f43f50..b14ec82 100644 --- a/update.html +++ b/update.html @@ -28,7 +28,7 @@ backup this file if you have done manually changes to it. installed languages)
  • /modules/installed_modules.php (contains information about -installed modules)
  • installed_extensions.php (contains information about installed extensions to the menu system)
  • +installed modules)
  • installed_extensions.php (contains information about installed extensions to the menu system)
  • if you have made changes to other files, like themes or so, backup these files too.
  • @@ -53,8 +53,11 @@ can download a new one of the new themes on the download page.  Go to the 'Setup' tab and run 'Software Upgrade'. Mark the checkbox 'Install' and press 'Upgrade System'.  This will -upgrade ALL your companies.
  • If something goes wrong during upgrade, you can enter here again and try 'Force Upgrade', and press 'Upgrade System' again.
  • There are no database changes during a major and minor release. Like from 2.1 to 2.1.1 - 2.1.5 .
  • +upgrade ALL your companies.
  • If something goes wrong during upgrade, you can enter here again and try 'Force Upgrade', and press 'Upgrade System' again.
  • There are no database changes during a major and minor release. Like from 2.1 to 2.1.1 - 2.1.5 .
  • When +updating from release 2.1.2 to 2.1.3, please go into Bank and General +Ledger tab. Enter Account Classes. Change the Class Types to a proper +value for all classes.
  • -

     

    +

     

    \ No newline at end of file