Code clean-up
authorJoe Hunt <joe.hunt.consulting@gmail.com>
Fri, 12 Jun 2009 08:48:32 +0000 (08:48 +0000)
committerJoe Hunt <joe.hunt.consulting@gmail.com>
Fri, 12 Jun 2009 08:48:32 +0000 (08:48 +0000)
CHANGELOG.txt
gl/includes/db/gl_db_trans.inc
gl/inquiry/gl_trial_balance.php
includes/ui/ui_view.inc
reporting/rep708.php
sql/en_US-demo.sql
sql/en_US-new.sql
update.html

index ee629ad8a715aceb2790ddeb5a498984f0eca521..00d347d4b2e2cffbf74edc4d5e2d0e549af90e23 100644 (file)
@@ -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
index 3570f9c3a5974c3b510c00cb42cf446ee4082924..76d293e0985032937fa4dc287522a55235e55532 100644 (file)
@@ -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)
index 6d33b98c7ff254cf373bd40e4102dcb05e3f351b..6bf807cd83416d131df584c1c31a188ad6435bca 100644 (file)
@@ -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);
index a1fb09ff2c4d3b850041dc5a1676f2fefc288e2d..e978b36d9b9564a931ad25a1cb14989915d00977 100644 (file)
@@ -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("");
-       }
 }
 
 //--------------------------------------------------------------------------------------
index f46cba8d1dadec355dfec02791d6f39b8da3f095..dd027188395336bf1ca0936948e6e5edffe40c10 100644 (file)
@@ -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()
index 8b80ee29b093cba6bcfdb9fd2aa2d8156f5798b1..028d4b4ca9aa92f5aa2f49007e84c220a1267694 100644 (file)
@@ -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` ###
index cda5540a1cc8aa50146727174899674f21669d9f..3821c7849bad3e0b13f8432bfe1136a2d4ef0fec 100644 (file)
@@ -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` ###
index 5f43f50a9f7fdc212ca4b001eb9779cd68447b6d..b14ec82fde45709448207806c6b6c138400e7b8f 100644 (file)
@@ -28,7 +28,7 @@ backup this file if you have done manually changes to it.
 installed languages)
           </li>
           <li><strong>/modules/installed_modules.php</strong> (contains information about
-installed modules<strong></strong>)</li><li>installed_extensions.php (contains information about installed extensions to the menu system)</li>
+installed modules<strong></strong>)</li><li><span style="font-weight: bold;">installed_extensions.php</span> (contains information about installed extensions to the menu system)</li>
           <li>if you have made <em>changes to other files</em>, like themes or so, backup
 these files too. </li>
         </ol>
@@ -53,8 +53,11 @@ can download a new one of the new themes on the download page.&nbsp; Go
 to the 'Setup' tab and run 'Software
 Upgrade'.
 Mark the checkbox 'Install' and press 'Upgrade System'. &nbsp;This will
-upgrade ALL your companies.</strong></li><li style="font-weight: bold;">If something goes wrong during upgrade, you can enter here again and try 'Force Upgrade', and press 'Upgrade System' again.</li><li><strong style="font-weight: bold;"></strong><strong>There are no database changes during a major and minor release. Like from 2.1 to 2.1.1 - 2.1.5 .</strong></li>
+upgrade ALL your companies.</strong></li><li style="font-weight: bold;">If something goes wrong during upgrade, you can enter here again and try 'Force Upgrade', and press 'Upgrade System' again.</li><li><strong style="font-weight: bold;"></strong><strong>There are no database changes during a major and minor release. Like from 2.1 to 2.1.1 - 2.1.5 .</strong></li><li style="font-weight: bold;">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.</li>
 </ul>
 
-<p>&nbsp;</p>
+<p style="font-weight: bold;">&nbsp;</p>
 </body></html>
\ No newline at end of file