X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;ds=sidebyside;f=gl%2Finquiry%2Fgl_trial_balance.php;h=8a6ba2f9c1c65ec251fb70a53a52d6549fb91f6f;hb=04e10a2fef964ee04596dc8d7672a6e55aa3987a;hp=d6587c3143365be774e3575a0f921f6a5e54dfcc;hpb=431531eebf3ba494002cfbf7ea36f9e82d4975c0;p=fa-stable.git diff --git a/gl/inquiry/gl_trial_balance.php b/gl/inquiry/gl_trial_balance.php index d6587c31..8a6ba2f9 100644 --- a/gl/inquiry/gl_trial_balance.php +++ b/gl/inquiry/gl_trial_balance.php @@ -40,9 +40,9 @@ function gl_inquiry_controls() function get_balance($account, $from, $to, $from_incl=true, $to_incl=true) { $sql = "SELECT SUM(amount) As TransactionSum FROM ".TB_PREF."gl_trans - WHERE account=$account"; + WHERE account='$account'"; - if ($from) + if ($from) { $from_date = date2sql($from); if ($from_incl) @@ -51,7 +51,7 @@ function get_balance($account, $from, $to, $from_incl=true, $to_incl=true) { $sql .= " AND tran_date > '$from_date'"; } - if ($to) + if ($to) { $to_date = date2sql($to); if ($to_incl) @@ -94,10 +94,18 @@ function display_trial_balance() $accounts = get_gl_accounts(); - while ($account = db_fetch($accounts)) + while ($account = db_fetch($accounts)) { - - $prev_balance = get_balance($account["account_code"], null, $_POST['TransFromDate'], false, false); + if (is_account_balancesheet($account["account_code"])) + $begin = null; + else + { + $begin = begin_fiscalyear(); + if ($_POST['TransFromDate'] < $begin) + $begin = $_POST['TransFromDate']; + $begin = add_days($begin, -1); + } + $prev_balance = get_balance($account["account_code"], $begin, $_POST['TransFromDate'], false, false); $curr_balance = get_balance($account["account_code"], $_POST['TransFromDate'], $_POST['TransToDate']); if (check_value("NoZero") && !$prev_balance && !$curr_balance)