From 1a5b277431e6804654cbca16aaed5ee3a5a729eb Mon Sep 17 00:00:00 2001 From: Joe Hunt Date: Thu, 11 Jun 2009 11:56:17 +0000 Subject: [PATCH] Changed balance_sheet operation in class table to class type for sign convert in Balance Sheet, Profit and Loss Statement and Monthly Breakdown --- CHANGELOG.txt | 12 ++++++++ gl/includes/db/gl_db_account_types.inc | 10 +++++++ gl/includes/db/gl_db_accounts.inc | 14 +++++---- gl/inquiry/gl_trial_balance.php | 2 +- gl/manage/gl_account_classes.php | 14 ++------- includes/types.inc | 16 ++++++++++ includes/ui/ui_lists.inc | 13 ++++++++ reporting/rep705.php | 40 ++++++++++++++----------- reporting/rep706.php | 41 +++++++++++++------------- reporting/rep707.php | 32 +++++++++++--------- reporting/rep708.php | 2 +- 11 files changed, 126 insertions(+), 70 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index baf92580..ee629ad8 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -19,6 +19,18 @@ Legend: ! -> Note $ -> Affected files +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 + /gl/includes/db/gl_db_account_types.inc + /gl/includes/db/gl_db_accounts.inc + /gl/inquiry/gl_trial_balance.php + /includes/types.inc + /reporting/rep705.php + /reporting/rep706.php + /reporting/rep707.php + /reporting/rep708.php + 09-Jun-2009 Joe Hunt # Bad format in due date column in search dimensions $ /dimensions/inquiry/search_dimensions.php diff --git a/gl/includes/db/gl_db_account_types.inc b/gl/includes/db/gl_db_account_types.inc index f5375bbd..d731b80b 100644 --- a/gl/includes/db/gl_db_account_types.inc +++ b/gl/includes/db/gl_db_account_types.inc @@ -100,6 +100,16 @@ 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) { diff --git a/gl/includes/db/gl_db_accounts.inc b/gl/includes/db/gl_db_accounts.inc index b544094e..bcecad74 100644 --- a/gl/includes/db/gl_db_accounts.inc +++ b/gl/includes/db/gl_db_accounts.inc @@ -51,13 +51,17 @@ function get_gl_accounts($from=null, $to=null) function get_gl_accounts_all($balance=-1) { - $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 + if ($balance == 1) + $where ="WHERE balance_sheet>0 AND balance_sheet<".CL_INCOME; + 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 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) - $sql .= "WHERE ".TB_PREF."chart_class.balance_sheet=$balance "; - $sql .= "ORDER BY ".TB_PREF."chart_class.cid, IF(parent > 0,parent,".TB_PREF."chart_types.id), + $sql .= $where; + $sql .= " ORDER BY ".TB_PREF."chart_class.cid, IF(parent > 0,parent,".TB_PREF."chart_types.id), IF(parent > 0,".TB_PREF."chart_types.id, parent), ".TB_PREF."chart_master.account_code"; return db_query($sql, "could not get gl accounts"); @@ -80,7 +84,7 @@ function is_account_balancesheet($code) $result = db_query($sql,"could not retreive the account class for $code"); $row = db_fetch_row($result); - return $row[0]; + return $row[0] > 0 && $row[0] < CL_INCOME; } function get_gl_account_name($code) diff --git a/gl/inquiry/gl_trial_balance.php b/gl/inquiry/gl_trial_balance.php index 27fc37df..6d33b98c 100644 --- a/gl/inquiry/gl_trial_balance.php +++ b/gl/inquiry/gl_trial_balance.php @@ -66,7 +66,7 @@ function get_balance($account, $from, $to, $from_incl=true, $to_incl=true) if ($from_incl) $sql .= " tran_date >= '$from_date' AND"; else - $sql .= " tran_date > IF(".TB_PREF."chart_class.balance_sheet=1, '0000-00-00', '$from_date') AND"; + $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' "; diff --git a/gl/manage/gl_account_classes.php b/gl/manage/gl_account_classes.php index 65a6429d..9015c583 100644 --- a/gl/manage/gl_account_classes.php +++ b/gl/manage/gl_account_classes.php @@ -106,7 +106,7 @@ if ($Mode == 'RESET') $result = get_account_classes(); start_form(); start_table($table_style); -$th = array(_("Class ID"), _("Class Name"), _("Balance Sheet"), "", ""); +$th = array(_("Class ID"), _("Class Name"), _("Class Type"), "", ""); table_header($th); $k = 0; @@ -115,17 +115,9 @@ while ($myrow = db_fetch($result)) alt_table_row_color($k); - if ($myrow["balance_sheet"] == 0) - { - $bs_text = _("No"); - } - else - { - $bs_text = _("Yes"); - } label_cell($myrow["cid"]); label_cell($myrow['class_name']); - label_cell($bs_text); + label_cell($class_types[$myrow["balance_sheet"]]); edit_button_cell("Edit".$myrow["cid"], _("Edit")); delete_button_cell("Delete".$myrow["cid"], _("Delete")); end_row(); @@ -163,7 +155,7 @@ else text_row_ex(_("Class Name:"), 'name', 50, 60); -yesno_list_row(_("Balance Sheet:"), 'Balance', null, "", "", false); +class_types_list_row(_("Class Type:"), 'Balance', null); end_table(1); diff --git a/includes/types.inc b/includes/types.inc index 38c3101b..e12efa0d 100644 --- a/includes/types.inc +++ b/includes/types.inc @@ -309,6 +309,22 @@ class wo_types } } +define('CL_ASSETS', 1); +define('CL_LIABILITIES', 2); +define('CL_EQUITY', 3); +define('CL_INCOME', 4); +define('CL_COGS', 5); +define('CL_EXPENSE', 6); + +$class_types = array( + CL_ASSETS => _("Assets"), + CL_LIABILITIES => _("Liabilities"), + CL_EQUITY => _("Equity"), + CL_INCOME => _("Income"), + CL_COGS => _("Cost of Goods Sold"), + CL_EXPENSE => _("Expense"), +); + define('WO_LABOUR', 0); define('WO_OVERHEAD', 1); diff --git a/includes/ui/ui_lists.inc b/includes/ui/ui_lists.inc index a1b65af1..f136c382 100644 --- a/includes/ui/ui_lists.inc +++ b/includes/ui/ui_lists.inc @@ -2067,4 +2067,17 @@ function quick_entry_types_list_row($label, $name, $selected_id=null, $submit_on } +function class_types_list_row($label, $name, $selected_id=null, $submit_on_change=false) +{ + global $class_types; + + echo "$label"; + array_selector($name, $selected_id, $class_types, + array( + 'select_submit'=> $submit_on_change + ) ); + echo "\n"; +} + + ?> \ No newline at end of file diff --git a/reporting/rep705.php b/reporting/rep705.php index b3927d4c..341d6e5d 100644 --- a/reporting/rep705.php +++ b/reporting/rep705.php @@ -47,18 +47,18 @@ function getPeriods($year, $account, $dimension, $dimension2) $date02 = date('Y-m-d',mktime(0,0,0,$mo-10,1,$yr)); $date01 = date('Y-m-d',mktime(0,0,0,$mo-11,1,$yr)); - $sql = "SELECT SUM(CASE WHEN tran_date >= '$date01' AND tran_date < '$date02' THEN -amount / 1000 ELSE 0 END) AS per01, - SUM(CASE WHEN tran_date >= '$date02' AND tran_date < '$date03' THEN -amount / 1000 ELSE 0 END) AS per02, - SUM(CASE WHEN tran_date >= '$date03' AND tran_date < '$date04' THEN -amount / 1000 ELSE 0 END) AS per03, - SUM(CASE WHEN tran_date >= '$date04' AND tran_date < '$date05' THEN -amount / 1000 ELSE 0 END) AS per04, - SUM(CASE WHEN tran_date >= '$date05' AND tran_date < '$date06' THEN -amount / 1000 ELSE 0 END) AS per05, - SUM(CASE WHEN tran_date >= '$date06' AND tran_date < '$date07' THEN -amount / 1000 ELSE 0 END) AS per06, - SUM(CASE WHEN tran_date >= '$date07' AND tran_date < '$date08' THEN -amount / 1000 ELSE 0 END) AS per07, - SUM(CASE WHEN tran_date >= '$date08' AND tran_date < '$date09' THEN -amount / 1000 ELSE 0 END) AS per08, - SUM(CASE WHEN tran_date >= '$date09' AND tran_date < '$date10' THEN -amount / 1000 ELSE 0 END) AS per09, - SUM(CASE WHEN tran_date >= '$date10' AND tran_date < '$date11' THEN -amount / 1000 ELSE 0 END) AS per10, - SUM(CASE WHEN tran_date >= '$date11' AND tran_date < '$date12' THEN -amount / 1000 ELSE 0 END) AS per11, - SUM(CASE WHEN tran_date >= '$date12' AND tran_date < '$date13' THEN -amount / 1000 ELSE 0 END) AS per12 + $sql = "SELECT SUM(CASE WHEN tran_date >= '$date01' AND tran_date < '$date02' THEN amount / 1000 ELSE 0 END) AS per01, + SUM(CASE WHEN tran_date >= '$date02' AND tran_date < '$date03' THEN amount / 1000 ELSE 0 END) AS per02, + SUM(CASE WHEN tran_date >= '$date03' AND tran_date < '$date04' THEN amount / 1000 ELSE 0 END) AS per03, + SUM(CASE WHEN tran_date >= '$date04' AND tran_date < '$date05' THEN amount / 1000 ELSE 0 END) AS per04, + SUM(CASE WHEN tran_date >= '$date05' AND tran_date < '$date06' THEN amount / 1000 ELSE 0 END) AS per05, + SUM(CASE WHEN tran_date >= '$date06' AND tran_date < '$date07' THEN amount / 1000 ELSE 0 END) AS per06, + SUM(CASE WHEN tran_date >= '$date07' AND tran_date < '$date08' THEN amount / 1000 ELSE 0 END) AS per07, + SUM(CASE WHEN tran_date >= '$date08' AND tran_date < '$date09' THEN amount / 1000 ELSE 0 END) AS per08, + SUM(CASE WHEN tran_date >= '$date09' AND tran_date < '$date10' THEN amount / 1000 ELSE 0 END) AS per09, + SUM(CASE WHEN tran_date >= '$date10' AND tran_date < '$date11' THEN amount / 1000 ELSE 0 END) AS per10, + SUM(CASE WHEN tran_date >= '$date11' AND tran_date < '$date12' THEN amount / 1000 ELSE 0 END) AS per11, + SUM(CASE WHEN tran_date >= '$date12' AND tran_date < '$date13' THEN amount / 1000 ELSE 0 END) AS per12 FROM ".TB_PREF."gl_trans WHERE account='$account'"; if ($dimension > 0) @@ -198,6 +198,9 @@ function print_annual_expense_breakdown() $level = 0; $last = -1; + $closeclass = false; + $convert = 1; + $accounts = get_gl_accounts_all(0); while ($account=db_fetch($accounts)) @@ -235,7 +238,7 @@ function print_annual_expense_breakdown() $rep->TextCol(0, 2, _('Total') . " " . $typename[$level]); for ($i = 1; $i <= 12; $i++) { - $rep->AmountCol($i + 1, $i + 2, $total[$level][$i], $dec); + $rep->AmountCol($i + 1, $i + 2, $total[$level][$i] * $convert, $dec); $total[$level][$i] = 0.0; } } @@ -252,7 +255,7 @@ function print_annual_expense_breakdown() $rep->TextCol(0, 2, _('Total') . " " . $classname); for ($i = 1; $i <= 12; $i++) { - $rep->AmountCol($i + 1, $i + 2, $total2[$i], $dec); + $rep->AmountCol($i + 1, $i + 2, $total2[$i] * $convert, $dec); $sales[$i] += $total2[$i]; } $rep->Font(); @@ -279,6 +282,7 @@ function print_annual_expense_breakdown() $rep->Line($rep->row); $rep->NewLine(); } + $convert = get_account_class_convert($account['ClassID']); $classname = $account['AccountClassName']; if ($account['account_code'] != null) @@ -291,7 +295,7 @@ function print_annual_expense_breakdown() for ($i = 1; $i <= 12; $i++) { - $rep->AmountCol($i + 1, $i + 2, $balance[$i], $dec); + $rep->AmountCol($i + 1, $i + 2, $balance[$i] * $convert, $dec); $total2[$i] += $balance[$i]; } for ($j = 0; $j <= $level; $j++) @@ -329,7 +333,7 @@ function print_annual_expense_breakdown() $rep->TextCol(0, 2, _('Total') . " " . $typename[$level]); for ($i = 1; $i <= 12; $i++) { - $rep->AmountCol($i + 1, $i + 2, $total[$level][$i], $dec); + $rep->AmountCol($i + 1, $i + 2, $total[$level][$i] * $convert, $dec); $total[$level][$i] = 0.0; } } @@ -347,14 +351,14 @@ function print_annual_expense_breakdown() $rep->TextCol(0, 2, _('Total') . " " . $classname); for ($i = 1; $i <= 12; $i++) { - $rep->AmountCol($i + 1, $i + 2, $total2[$i], $dec); + $rep->AmountCol($i + 1, $i + 2, $total2[$i] * $convert, $dec); $calc[$i] = $sales[$i] + $total2[$i]; } $rep->NewLine(2); $rep->TextCol(0, 2, _('Calculated Return')); for ($i = 1; $i <= 12; $i++) - $rep->AmountCol($i + 1, $i + 2, $calc[$i], $dec); + $rep->AmountCol($i + 1, $i + 2, $calc[$i] * -1, $dec); // always convert $rep->Font(); $rep->NewLine(); diff --git a/reporting/rep706.php b/reporting/rep706.php index b7b67e89..91261cf8 100644 --- a/reporting/rep706.php +++ b/reporting/rep706.php @@ -118,11 +118,12 @@ function print_balance_sheet() $typeclose = array(0,0,0,0,0,0,0,0,0,0); $typename = array('','','','','','','','','',''); $closing = array(-1,-1,-1,-1,-1,-1,-1,-1,-1,-1); - $parent = array(-1,-1,-1,-1,-1,-1,-1,-1,-1,-1); + //$parent = array(-1,-1,-1,-1,-1,-1,-1,-1,-1,-1); $level = 0; $last = -1; $closeclass = false; + $convert = 1; $rep->NewLine(); $accounts = get_gl_accounts_all(1); @@ -147,7 +148,6 @@ function print_balance_sheet() $closeclass = true; } } - if ($account['AccountTypeName'] != $typename[$level]) { //$rep->NewLine(); @@ -163,9 +163,9 @@ function print_balance_sheet() $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); + $rep->AmountCol(2, 3, $typeopen[$level] * $convert, $dec); + $rep->AmountCol(3, 4, $typeperiod[$level] * $convert, $dec); + $rep->AmountCol(4, 5, $typeclose[$level] * $convert, $dec); if ($graphics) { $pg->x[] = $typename[$level]; @@ -185,9 +185,9 @@ function print_balance_sheet() $rep->NewLine(); $rep->Font('bold'); $rep->TextCol(0, 2, _('Total') . " " . $classname); - $rep->AmountCol(2, 3, $classopen, $dec); - $rep->AmountCol(3, 4, $classperiod, $dec); - $rep->AmountCol(4, 5, $classclose, $dec); + $rep->AmountCol(2, 3, $classopen * $convert, $dec); + $rep->AmountCol(3, 4, $classperiod * $convert, $dec); + $rep->AmountCol(4, 5, $classclose * $convert, $dec); $rep->Font(); $assetsopen += $classopen; $assetsperiod += $classperiod; @@ -215,6 +215,7 @@ function print_balance_sheet() $rep->Line($rep->row); $rep->NewLine(); } + $convert = get_account_class_convert($account['ClassID']); $classname = $account['AccountClassName']; if ($account['account_code'] != null) @@ -231,9 +232,9 @@ function print_balance_sheet() $rep->TextCol(0, 1, $account['account_code']); $rep->TextCol(1, 2, $account['account_name']); - $rep->AmountCol(2, 3, $prev_balance, $dec); - $rep->AmountCol(3, 4, $curr_balance, $dec); - $rep->AmountCol(4, 5, $curr_balance + $prev_balance, $dec); + $rep->AmountCol(2, 3, $prev_balance * $convert, $dec); + $rep->AmountCol(3, 4, $curr_balance * $convert, $dec); + $rep->AmountCol(4, 5, ($curr_balance + $prev_balance) * $convert, $dec); $rep->NewLine(); @@ -263,9 +264,9 @@ function print_balance_sheet() $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); + $rep->AmountCol(2, 3, $typeopen[$level] * $convert, $dec); + $rep->AmountCol(3, 4, $typeperiod[$level] * $convert, $dec); + $rep->AmountCol(4, 5, $typeclose[$level] * $convert, $dec); if ($graphics) { $pg->x[] = $typename[$level]; @@ -287,9 +288,9 @@ function print_balance_sheet() $rep->Line($rep->row); $rep->NewLine(); $rep->TextCol(0, 2, _('Calculated Return')); - $rep->AmountCol(2, 3, $calculateopen, $dec); - $rep->AmountCol(3, 4, $calculateperiod, $dec); - $rep->AmountCol(4, 5, $calculateclose, $dec); + $rep->AmountCol(2, 3, $calculateopen * $convert, $dec); + $rep->AmountCol(3, 4, $calculateperiod * $convert, $dec); + $rep->AmountCol(4, 5, $calculateclose * $convert, $dec); if ($graphics) { $pg->x[] = _('Calculated Return'); @@ -298,9 +299,9 @@ function print_balance_sheet() $rep->NewLine(2); $rep->Font('bold'); $rep->TextCol(0, 2, _('Total') . " " . $classname); - $rep->AmountCol(2, 3, -$assetsopen, $dec); - $rep->AmountCol(3, 4, -$assetsperiod, $dec); - $rep->AmountCol(4, 5, -$assetsclose, $dec); + $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(); } diff --git a/reporting/rep707.php b/reporting/rep707.php index 5dd9c1b2..df551fc3 100644 --- a/reporting/rep707.php +++ b/reporting/rep707.php @@ -154,6 +154,9 @@ function print_profit_and_loss_statement() $salesacc = 0.0; $last = -1; + $closeclass = false; + $convert = 1; + $accounts = get_gl_accounts_all(0); while ($account=db_fetch($accounts)) @@ -193,8 +196,8 @@ function print_profit_and_loss_statement() $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(2, 3, $typeper[$level] * $convert, $dec); + $rep->AmountCol(3, 4, $typeacc[$level] * $convert, $dec); $rep->AmountCol(4, 5, Achieve($typeper[$level], $typeacc[$level]), $pdec); if ($graphics) { @@ -216,8 +219,8 @@ function print_profit_and_loss_statement() $rep->NewLine(); $rep->Font('bold'); $rep->TextCol(0, 2, _('Total') . " " . $classname); - $rep->AmountCol(2, 3, $classper, $dec); - $rep->AmountCol(3, 4, $classacc, $dec); + $rep->AmountCol(2, 3, $classper * $convert, $dec); + $rep->AmountCol(3, 4, $classacc * $convert, $dec); $rep->AmountCol(4, 5, Achieve($classper, $classacc), $pdec); $rep->Font(); $salesper += $classper; @@ -245,12 +248,13 @@ function print_profit_and_loss_statement() $rep->Line($rep->row); $rep->NewLine(); } + $convert = get_account_class_convert($account['ClassID']); $classname = $account['AccountClassName']; if ($account['account_code'] != null) { - $per_balance *= -1; - $acc_balance *= -1; + //$per_balance *= -1; + //$acc_balance *= -1; for ($i = 0; $i <= $level; $i++) { @@ -262,8 +266,8 @@ function print_profit_and_loss_statement() $rep->TextCol(0, 1, $account['account_code']); $rep->TextCol(1, 2, $account['account_name']); - $rep->AmountCol(2, 3, $per_balance, $dec); - $rep->AmountCol(3, 4, $acc_balance, $dec); + $rep->AmountCol(2, 3, $per_balance * $convert, $dec); + $rep->AmountCol(3, 4, $acc_balance * $convert, $dec); $rep->AmountCol(4, 5, Achieve($per_balance, $acc_balance), $pdec); $rep->NewLine(); @@ -294,8 +298,8 @@ function print_profit_and_loss_statement() $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(2, 3, $typeper[$level] * $convert, $dec); + $rep->AmountCol(3, 4, $typeacc[$level] * $convert, $dec); $rep->AmountCol(4, 5, Achieve($typeper[$level], $typeacc[$level]), $pdec); if ($graphics) { @@ -321,14 +325,14 @@ function print_profit_and_loss_statement() $rep->Font('bold'); $rep->TextCol(0, 2, _('Total') . " " . $classname); - $rep->AmountCol(2, 3, $classper, $dec); - $rep->AmountCol(3, 4, $classacc, $dec); + $rep->AmountCol(2, 3, $classper * $convert, $dec); + $rep->AmountCol(3, 4, $classacc * $convert, $dec); $rep->AmountCol(4, 5, Achieve($classper, $classacc), $pdec); $rep->NewLine(2); $rep->TextCol(0, 2, _('Calculated Return')); - $rep->AmountCol(2, 3, $calculateper, $dec); - $rep->AmountCol(3, 4, $calculateacc, $dec); + $rep->AmountCol(2, 3, $calculateper *-1, $dec); // always convert + $rep->AmountCol(3, 4, $calculateacc * -1, $dec); $rep->AmountCol(4, 5, Achieve($calculateper, $calculateacc), $pdec); if ($graphics) { diff --git a/reporting/rep708.php b/reporting/rep708.php index 6f3086b5..f46cba8d 100644 --- a/reporting/rep708.php +++ b/reporting/rep708.php @@ -45,7 +45,7 @@ function get_balance($account, $dimension, $dimension2, $from, $to, $from_incl=t if ($from_incl) $sql .= " tran_date >= '$from_date' AND"; else - $sql .= " tran_date > IF(".TB_PREF."chart_class.balance_sheet=1, '0000-00-00', '$from_date') AND"; + $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' "; -- 2.30.2