-//---------------------------------------------------------------------------------------------
-function close_year($year)
-{
- $myrow = get_fiscalyear($year);
- $to = $myrow['end'];
- // retrieve total balances from balance sheet accounts
- $sql = "SELECT SUM(amount) FROM ".TB_PREF."gl_trans INNER JOIN ".TB_PREF."chart_master ON account=account_code
- INNER JOIN ".TB_PREF."chart_types ON account_type=id INNER JOIN ".TB_PREF."chart_class ON class_id=cid
- WHERE balance_sheet=1 AND tran_date <= '$to'";
- $result = db_query($sql, "The total balance could not be calculated");
-
- $row = db_fetch_row($result);
- $balance = round2($row[0], user_price_dec());
- if ($balance != 0.0)
- {
- $co = get_company_prefs();
- $to = sql2date($to);
-
- begin_transaction();
-
- $trans_type = systypes::journal_entry();
- $trans_id = get_next_trans_no($trans_type);