Fixed so nested subtypes in account types are nested correctly in Balance Sheet and P&L Statement
! -> 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
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";
$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"];
$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();
}
}
- 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)
{
$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;
$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;
$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)
$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;
}
}
- 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)
{
$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;
$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']);
$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)