- $trans_type = ST_JOURNAL;
- $trans_id = get_next_trans_no($trans_type);
-
- add_gl_trans($trans_type, $trans_id, $to, $co['retained_earnings_act'],
- 0, 0, _("Closing Year"), -$balance);
- add_gl_trans($trans_type, $trans_id, $to, $co['profit_loss_year_act'],
- 0, 0, _("Closing Year"), $balance);
-
- }
+ $cart = new items_cart(ST_JOURNAL);
+ $cart->reference = $Refs->get_next(ST_JOURNAL, null, sql2date($to));
+ $cart->tran_date = $cart->doc_date = $cart->event_date = $to;
+
+ $cart->add_gl_item($co['retained_earnings_act'], 0, 0, -$balance, _("Closing Year"), '', 0);
+ $cart->add_gl_item($co['profit_loss_year_act'], 0, 0, $balance, _("Closing Year"), '', 0);
+ $cart->memo_ = _("Closing Year");
+ write_journal_entries($cart);
+ }