Fixed Supplier Credit so Purchase Order Outstanding is decreased too.
authorJoe Hunt <joe.hunt.consulting@gmail.com>
Mon, 25 May 2009 12:54:26 +0000 (12:54 +0000)
committerJoe Hunt <joe.hunt.consulting@gmail.com>
Mon, 25 May 2009 12:54:26 +0000 (12:54 +0000)
Fixed so nested subtypes in account types are nested correctly in Balance Sheet and P&L Statement

CHANGELOG.txt
gl/includes/db/gl_db_accounts.inc
purchasing/includes/db/grn_db.inc
reporting/rep706.php
reporting/rep707.php

index 290c88daaabe32a62b8dbc8bb7c97d27589bb7d4..fb24fbcac8cc77f822aa4dbb61a7704bcb41714a 100644 (file)
@@ -19,6 +19,14 @@ Legend:
 ! -> Note
 $ -> Affected files
 
+25-May-2009 Joe Hunt
+# Fixed Supplier Credit so Purchase Order Outstanding is decreased too.
+$ /purchasing/includes/db/grn_db.inc
+# Fixed so nested subtypes in account types are nested correctly in Balance Sheet and P&L Statement
+$ /gl/includes/db/gl_db_accounts.inc
+$ /reporting/rep706.php
+$ /reporting/rep707.php
+
 23-May-2009 Janusz Dobrowolski
 # Fixed transaction table search update.
 $ /admin/view_print_transaction.php
index 9622ebc26a837d1d4b7dd93323bec318b2260a01..695743d8af6818878cdd63ef0996fc9a0cfce303 100644 (file)
@@ -51,7 +51,8 @@ function get_gl_accounts($from=null, $to=null)
 
 function get_gl_accounts_all($balance=-1)
 {
-       $sql = "SELECT ".TB_PREF."chart_master.*,".TB_PREF."chart_types.name AS AccountTypeName,".TB_PREF."chart_class.class_name AS AccountClassName
+       $sql = "SELECT ".TB_PREF."chart_master.*,".TB_PREF."chart_types.name AS AccountTypeName,".TB_PREF."chart_types.parent,
+               ".TB_PREF."chart_class.class_name AS AccountClassName
                FROM ".TB_PREF."chart_master,".TB_PREF."chart_types, ".TB_PREF."chart_class
                WHERE ".TB_PREF."chart_master.account_type=".TB_PREF."chart_types.id AND
                ".TB_PREF."chart_types.class_id=".TB_PREF."chart_class.cid";
index c0fdf54ac824bb3e3cdce1ef1ce7f461d1b1745d..9b56b0f747608a7bd1391ac670b1067756862d33 100644 (file)
@@ -169,6 +169,8 @@ function set_grn_item_credited(&$entered_grn, $supplier, $transno, $date)
 
        $sql = "UPDATE ".TB_PREF."purch_order_details
         SET quantity_received = quantity_received + $entered_grn->this_quantity_inv,
+        quantity_ordered = quantity_ordered + $entered_grn->this_quantity_inv,
+        qty_invoiced = qty_invoiced + $entered_grn->this_quantity_inv,
         std_cost_unit=$mcost,
         act_price=$entered_grn->chg_price
         WHERE po_detail_item = ".$myrow["po_detail_item"];
index d045d5583251d77b66f49b470c3b5b7ef964d6eb..f490e08d4ee942287f1630402490b8c141723a50 100644 (file)
@@ -106,16 +106,20 @@ function print_balance_sheet()
        $rep->Info($params, $cols, $headers, $aligns);
        $rep->Header();
        $classname = '';
-       $group = '';
-       $totalopen = 0.0;
-       $totalperiod = 0.0;
-       $totalclose = 0.0;
        $classopen = 0.0;
        $classperiod = 0.0;
        $classclose = 0.0;
        $assetsopen = 0.0;
        $assetsperiod = 0.0;
        $assetsclose = 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);
+       $typeclose = array(0,0,0,0,0,0,0,0,0,0);
+       $typename = array('','','','','','','','','','');
+       $parent = array(-1,-1,-1,-1,-1,-1,-1,-1,-1,-1);
+       $level = 0;
+       
        $closeclass = false;
        $rep->NewLine();
 
@@ -138,23 +142,29 @@ function print_balance_sheet()
                        }
                }
 
-               if ($account['AccountTypeName'] != $group)
+               if ($account['AccountTypeName'] != $typename[$level])
                {
-                       if ($group != '')
+                       if ($typename[$level] != '' && $account['parent'] == -1)
                        {
-                               $rep->row += 6;
-                               $rep->Line($rep->row);
-                               $rep->NewLine();
-                               $rep->TextCol(0, 2,     _('Total') . " " . $group);
-                               $rep->AmountCol(2, 3, $totalopen, $dec);
-                               $rep->AmountCol(3, 4, $totalperiod, $dec);
-                               $rep->AmountCol(4, 5, $totalclose, $dec);
+                               for ( ; $level >= 0; $level--)
+                               {
+                                       $rep->row += 6;
+                                       $rep->Line($rep->row);
+                                       $rep->NewLine();
+                                       $rep->TextCol(0, 2,     _('Total') . " " . $typename[$level]);
+                                       $rep->AmountCol(2, 3, $typeopen[$level], $dec);
+                                       $rep->AmountCol(3, 4, $typeperiod[$level], $dec);
+                                       $rep->AmountCol(4, 5, $typeclose[$level], $dec);
+                                       $typeopen[$level] = $typeperiod[$level] = $typeclose[$level] = 0.0;
+                                       if ($parent[$level] == -1)
+                                               break;
+                                       $rep->NewLine();
+                               }
                                if ($graphics)
                                {
-                                       $pg->x[] = $group;
-                                       $pg->y[] = abs($totalclose);
+                                       $pg->x[] = $$typename[$level];
+                                       $pg->y[] = abs($typeclose[$level]);
                                }
-                               $totalopen = $totalperiod = $totalclose = 0.0;
                                $rep->NewLine();
                                if ($closeclass)
                                {
@@ -182,7 +192,9 @@ function print_balance_sheet()
                                $rep->Font();
                                $rep->NewLine();
                        }
-                       $group = $account['AccountTypeName'];
+                       if ($account['parent'] != -1 && $account['parent'] != $parent[$level])
+                               $level++;
+                       $typename[$level] = $account['AccountTypeName'];
                        $rep->row -= 4;
                        $rep->TextCol(0, 5, $account['AccountTypeName']);
                        $rep->row -= 4;
@@ -190,10 +202,14 @@ function print_balance_sheet()
                        $rep->NewLine();
                }
                $classname = $account['AccountClassName'];
+               $parent[$level] = $account['parent'];   
 
-               $totalopen += $prev_balance;
-               $totalperiod += $curr_balance;
-               $totalclose = $totalopen + $totalperiod;
+               for ($i = 0; $i <= $level; $i++)
+               {
+                       $typeopen[$i] += $prev_balance;
+                       $typeperiod[$i] += $curr_balance;
+                       $typeclose[$i] = $typeopen[$i] + $typeperiod[$i];
+               }
                $classopen += $prev_balance;
                $classperiod += $curr_balance;
                $classclose = $classopen + $classperiod;
@@ -219,21 +235,28 @@ function print_balance_sheet()
                        $closeclass = true;
                }
        }
-       if ($account['AccountTypeName'] != $group)
+       if ($account['AccountTypeName'] != $typename[$level])
        {
-               if ($group != '')
+               if ($typename[$level] != '')
                {
-                       $rep->row += 6;
-                       $rep->Line($rep->row);
-                       $rep->NewLine();
-                       $rep->TextCol(0, 2,     _('Total') . " " . $group);
-                       $rep->AmountCol(2, 3, $totalopen, $dec);
-                       $rep->AmountCol(3, 4, $totalperiod, $dec);
-                       $rep->AmountCol(4, 5, $totalclose, $dec);
+                       for ( ; $level >= 0; $level--)
+                       {
+                               $rep->row += 6;
+                               $rep->Line($rep->row);
+                               $rep->NewLine();
+                               $rep->TextCol(0, 2,     _('Total') . " " . $typename[$level]);
+                               $rep->AmountCol(2, 3, $typeopen[$level], $dec);
+                               $rep->AmountCol(3, 4, $typeperiod[$level], $dec);
+                               $rep->AmountCol(4, 5, $typeclose[$level], $dec);
+                               $typeopen[$level] = $typeperiod[$level] = $typeclose[$level] = 0.0;
+                               if ($parent[$level] == -1)
+                                       break;
+                               $rep->NewLine();
+                       }
                        if ($graphics)
                        {
-                               $pg->x[] = $group;
-                               $pg->y[] = abs($totalclose);
+                               $pg->x[] = $$typename[$level];
+                               $pg->y[] = abs($typeclose[$level]);
                        }
                        $rep->NewLine();
                        if ($closeclass)
index 5dd3ff5c4f434bf9466c43ec4441110522e90d6f..d562218b5d5e2896cef02b6f13db6e3fbaffe06e 100644 (file)
@@ -141,9 +141,13 @@ function print_profit_and_loss_statement()
        $rep->Header();
 
        $classname = '';
-       $group = '';
-       $totalper = 0.0;
-       $totalacc = 0.0;
+       
+       $typeper = array(0,0,0,0,0,0,0,0,0,0);
+       $typeacc = array(0,0,0,0,0,0,0,0,0,0);
+       $typename = array('','','','','','','','','','');
+       $parent = array(-1,-1,-1,-1,-1,-1,-1,-1,-1,-1);
+       $level = 0;
+
        $classper = 0.0;
        $classacc = 0.0;
        $salesper = 0.0;
@@ -170,24 +174,30 @@ function print_profit_and_loss_statement()
                        }
                }
 
-               if ($account['AccountTypeName'] != $group)
+               if ($account['AccountTypeName'] != $typename[$level])
                {
-                       if ($group != '')
+                       if ($typename[$level] != '' && $account['parent'] == -1)
                        {
-                               $rep->row += 6;
-                               $rep->Line($rep->row);
-                               $rep->NewLine();
-                               $rep->TextCol(0, 2,     _('Total') . " " . $group);
-                               $rep->AmountCol(2, 3, $totalper, $dec);
-                               $rep->AmountCol(3, 4, $totalacc, $dec);
-                               $rep->AmountCol(4, 5, Achieve($totalper, $totalacc), $pdec);
+                               for ( ; $level >= 0; $level--)
+                               {
+                                       $rep->row += 6;
+                                       $rep->Line($rep->row);
+                                       $rep->NewLine();
+                                       $rep->TextCol(0, 2,     _('Total') . " " . $typename[$level]);
+                                       $rep->AmountCol(2, 3, $typeper[$level], $dec);
+                                       $rep->AmountCol(3, 4, $typeacc[$level], $dec);
+                                       $rep->AmountCol(4, 5, Achieve($typeper[$level], $typeacc[$level]), $pdec);
+                                       $typeper[$level] = $typeacc[$level] = 0.0;
+                                       if ($parent[$level] == -1)
+                                               break;
+                                       $rep->NewLine();
+                               }
                                if ($graphics)
                                {
-                                       $pg->x[] = $group;
-                                       $pg->y[] = abs($totalper);
-                                       $pg->z[] = abs($totalacc);
+                                       $pg->x[] = $typename[$level];
+                                       $pg->y[] = abs($typeper[$level]);
+                                       $pg->z[] = abs($typeacc[$level]);
                                }
-                               $totalper = $totalacc = 0.0;
                                $rep->NewLine();
                                if ($closeclass)
                                {
@@ -214,7 +224,9 @@ function print_profit_and_loss_statement()
                                $rep->Font();
                                $rep->NewLine();
                        }
-                       $group = $account['AccountTypeName'];
+                       if ($account['parent'] != -1 && $account['parent'] != $parent[$level])
+                               $level++;
+                       $typename[$level] = $account['AccountTypeName'];
                        $rep->row -= 4;
                        $rep->TextCol(0, 5, $account['AccountTypeName']);
                        $rep->row -= 4;
@@ -222,11 +234,16 @@ function print_profit_and_loss_statement()
                        $rep->NewLine();
                }
                $classname = $account['AccountClassName'];
+               $parent[$level] = $account['parent'];   
 
                $per_balance *= -1;
                $acc_balance *= -1;
-               $totalper += $per_balance;
-               $totalacc += $acc_balance;
+               
+               for ($i = 0; $i <= $level; $i++)
+               {
+                       $typeper[$i] += $per_balance;
+                       $typeacc[$i] += $acc_balance;
+               }
                $classper += $per_balance;
                $classacc += $acc_balance;
                $rep->TextCol(0, 1,     $account['account_code']);
@@ -251,22 +268,29 @@ function print_profit_and_loss_statement()
                        $closeclass = true;
                }
        }
-       if ($account['AccountTypeName'] != $group)
+       if ($account['AccountTypeName'] != $typename[$level])
        {
-               if ($group != '')
+               if ($typename[$level] != '')
                {
-                       $rep->row += 6;
-                       $rep->Line($rep->row);
-                       $rep->NewLine();
-                       $rep->TextCol(0, 2,     _('Total') . " " . $group);
-                       $rep->AmountCol(2, 3, $totalper, $dec);
-                       $rep->AmountCol(3, 4, $totalacc, $dec);
-                       $rep->AmountCol(4, 5, Achieve($totalper, $totalacc), $pdec);
+                       for ( ; $level >= 0; $level--)
+                       {
+                               $rep->row += 6;
+                               $rep->Line($rep->row);
+                               $rep->NewLine();
+                               $rep->TextCol(0, 2,     _('Total') . " " . $typename[$level]);
+                               $rep->AmountCol(2, 3, $typeper[$level], $dec);
+                               $rep->AmountCol(3, 4, $typeacc[$level], $dec);
+                               $rep->AmountCol(4, 5, Achieve($typeper[$level], $typeacc[$level]), $pdec);
+                               $typeper[$level] = $typeacc[$level] = 0.0;
+                               if ($parent[$level] == -1)
+                                       break;
+                               $rep->NewLine();
+                       }
                        if ($graphics)
                        {
-                               $pg->x[] = $group;
-                               $pg->y[] = abs($totalper);
-                               $pg->z[] = abs($totalacc);
+                               $pg->x[] = $typename[$level];
+                               $pg->y[] = abs($typeper[$level]);
+                               $pg->z[] = abs($typeacc[$level]);
                        }
                        $rep->NewLine();
                        if ($closeclass)